lucene-java-user mailing list archives

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

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.

Otis

--- jt oob <jt2oob@yahoo.co.uk> 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
> http://uk.messenger.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message