lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: Searching for doc without a field
Date Fri, 04 Feb 2005 21:03:02 GMT
On Friday 04 February 2005 17:29, Bill Tschumy wrote:
> 
> On Feb 4, 2005, at 10:19 AM, Bill Tschumy wrote:
> 
> >
> > On Feb 3, 2005, at 2:04 PM, Paul Elschot wrote:
> >
> >> On Thursday 03 February 2005 20:18, Bill Tschumy wrote:
> >>> Is there any way to construct a query to locate all documents 
> >>> without a
> >>> specific field?  By this I mean the Document was created without ever
> >>> having that field added to it.
> >>
> >> One way is to add an extra document field containing the field
> >> names of all (other) indexed fields in the document.
> >> Assuming there is always a primary key field the query is then:
> >>
> >> +fieldnames:primarykeyfield -fieldnames:specificfield
> >>
> >> Regards,
> >> Paul Elschot
> >
> > Paul,
> >
> > Thanks for the suggestion, but I need to do this on an existing 
> > database as it is.
> >
> > It just occurred to me that I should try a query on the field with a 
> > value of NULL.  Don't know if that will work or not.
> 
> Nope, using null as a search value just result in a 
> NullPointerException.

It's not impossible, but the problem is that the term index is first sorted
by field name, then by term text, then by document number, and then
by term position within document.

That means that the index path is no good to query for field name and
document number: you have to check all indexed terms in  between.

Lucene "only" allows to find the existence of a indexed field, the
indexed terms (field name + term text) in sorted order from a given term,
and the indexed documents of a term, possibly combined with the
with the term positions within each document.

The solution above shortcuts the index path by putting the field name
in place of the term text for a special field.

Regards,
Paul Elschot.


---------------------------------------------------------------------
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