lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Check if a field exists of not in a query
Date Fri, 24 Aug 2007 08:40:56 GMT
In the latest version of Lucene you can make a query like of myfield: 
[* TO *] to find all documents that have the field.

I've been using Solr so much lately that I'm used to doing the  
inverse to find ones that don't have a value for a field also:

	-myfield:[* TO *]

But Lucene itself does not support purely negative queries so you can  
combine that with a match-all-docs query:

	*:* AND -myfield:[* TO *]


On Aug 24, 2007, at 4:31 AM, Jean-Claude Antonio wrote:

> Hello,
> Sorry if this question was already asked, but I could not find  
> subjects related to it.
> Is it possible in a query to check if a field exists of not.
> something like:
> myfield:EXIST
> or myfield:ANY VALUE
> I had a look at the Query Parser Syntax, and I could not find  
> anything on the subject.
> Thanks in advance.
> *Jean-Claude Antonio*

View raw message