Hi Bill,

A simpler suggestion, assuming you need to test for the existence of just one 
particular field: rather than adding a field containing a list of all indexed 
fields for a particular document, as Karsten suggested, you could just add a 
field with a constant value when the field you want to test for is present for 
a particular document.

For example, if "foo" is a field you want to test for, and a document contains:

   foo:bar

you could add a new field "foo.present", with a constant value, to the document:

   foo.present:true

and then when querying:

   +foo.present:true

Steve

On 08/18/2008 at 11:45 AM, Karsten F. wrote:
> Hi Bill,
> 
> you should not use prefix-query (XXXX*), because in first
> step lucene would generate a list of all terms in this field,
> and than search for all this terms. Which is senceless.
> 
> I would suggest to insert a new field "myFields" which
> contains as value the names of all fields for this document.
> So instead of
>             +foo:XXXX*
> you would search for
>             +myFields:foo
> 
> This would be very fast.
> 
> Best regards
> 
>   Karsten
> 
> Bill.Chesky wrote:
> > 
> > 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));
> > ...
> > 
> > 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*
> > 
> 
> -- View this message in context:
> http://www.nabble.com/Testing-for-field-existence-tp19032939p1
> 9034359.html Sent from the Lucene - Java Users mailing list archive at
> Nabble.com.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to