Mailing List Archive

Check if a field exists of not in a query
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*
Re: Check if a field exists of not in a query [ In reply to ]
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 *]


Erik

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*