You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Benjamin Pasero <be...@gmail.com> on 2010/02/09 18:04:35 UTC

Creating a Query that matches Documents without a specific Field set?

Hi,

is there any way I can search for Documents that have a specific Field not set?

The use case is obvious: Consider you introduce a new field to your
documents but dont want to migrate all other documents,
how would you be able to write a Query that covers both old and new documents?

I was hoping that a simple TermQuery where the term value was set to
be an empty String would help me out but I was prooven
wrong.

Thanks for helping,
Ben

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


Re: Creating a Query that matches Documents without a specific Field set?

Posted by Ahmet Arslan <io...@yahoo.com>.
> is there any way I can search for Documents that have a
> specific Field not set?

Yes. If you are using QueryParser  *:* -specificField:[* TO *]
 
> I was hoping that a simple TermQuery where the term value
> was set to be an empty String would help me out but I was prooven
> wrong.

org.apache.lucene.search.MatchAllDocsQuery combined with RangeQuery can do that if you are constructing your queries programmatically.


      

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