lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan GuÅūvinec <ivan.guzvi...@gmail.com>
Subject Re: Field searching for nothing
Date Sat, 09 Apr 2005 13:12:24 GMT
I believe there isn't. I don't think any of the existing QueryParsers 
implements "search empty field" expression.

The way you might solve this requirement is to use a special "empty term" 
for such fields. For instance, I use single underscore "_" as a value for 
all empty fields in the document. I also use Keyword field to store this 
value verbatim (avoid Analyser that might not want to index a single 
underscore).

Searching for "empty term" can then be performed programmaticaly with a 
TermQuery:
indexSearcher.Search(new TermQuery(new Term("author", "_")));

General guide for the "empty term" value would be to choose a term that does 
not occur in any text you put into your index.


On Apr 9, 2005 12:44 AM, Bruce Best (CRO) <bestb@lao.on.ca> wrote:
> Is there any syntax to find all the documents where a particular
> Lucene-indexed field is empty?
> 
> For instance, say there is a field called "author". I can do a field 
search
> for
> author:cutting
> to find all documents with "cutting" in the author field; I could also
> search for
> author:"*"
> which would return all documents, whether there was something in the 
author
> field or not.
> 
> What if I wanted to find all those documents that had nothing at all in 
the
> "author" field? I tried a few combinations of wildcards and other various
> Lucene symbols, but they generally resulted in errors.
> 
> Is it possible with Lucene to specify "Return all documents where fieldx: 
is
> empty"?
> 
> Thanks,
> 
> B.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
>

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