Hello,
I am creating fields for documents like this:
String name = ...
String value = ...
doc.add(new Field(name, value, Field.Store.NO,
Field.Index.UN_TOKENIZED));
On the query side, sometimes I want to want to search for documents for
which a given field, say 'foo' is equal to a given value, say 'bar'.
E.g.
+foo:bar
This works.
But other times I just want to query to find all docuements for which a
given field exists regardless of its value. Is there a query that I can
do for this?
One thing I tried is to change my field creation statement like this:
doc.add(new Field(name, "XXXX" + value, Field.Store.NO,
Field.Index.UN_TOKENIZED));
then do a query like this:
+foo:XXXX*
I thought the "XXXX" at the beginning would be necessary since I read
that you cannot query with "*" at the beginning of your query string.
Anyway, it did not work. Is this because I'm storing the field
"UN_TOKENIZED"? Do I need to tokenize it to to be able to query against
it with wildcards, etc.?
Maybe there is a better more canonical way to do this? I'm still
pretty new to Lucene. Any help appreciated.
regards,
Bill