lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <>
Subject Re: Selecting documents which have field x
Date Fri, 18 Jun 2004 12:12:52 GMT

The best/easiest/only way I can think of to handle this is to have
another field that serves as a flag.  You could add that field only
when your document has that optional field.
Actually, you may also be able to make use of the ability to add
multiple values to the same field.  Then you could pick some obscure
and/or reserved value for a field to serve as a marker.

Something along the lines of:

if (oh, this type of doc has field X) {
 doc.add(Field.UnStored("fieldName", "field value here"));
 doc.add(Field.UnStored("fieldName", "__flag"));

Then you can search for fieldName:__flag and you will find all
documents with "fieldName".

The choice of __flag may not be the best, but you can play with it and
see what works best for you.


--- jt oob <> wrote:
> Is it possible/what's the best way, to find all documents which have
> a
> given field. The field contents may be the empty string "".
> Thanks,
> jt
> ___________________________________________________________ALL-NEW
> Yahoo! Messenger - sooooo many all-new ways to express yourself
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message