lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Bill.Che...@sungard.com>
Subject Testing for field existence
Date Mon, 18 Aug 2008 14:28:17 GMT
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

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message