Hmmm... I thought that worked in edismax. And I thought that pure negative queries were allowed in SolrQueryParser. Oh well.
In any case, in the Lucene or Solr query parser, add "*:*" to select all 
docs before negating the docs that have any value in the field:
(*:* -fname:*) OR fname:(A B C)

or

(*:* -fname:[* TO *]) OR fname:(A B C)

-- Jack Krupansky

-----Original Message----- From: Jack Krupansky
Sent: Wednesday, May 02, 2012 7:52 PM
To: solr-user@lucene.apache.org
Subject: Re: syntax for negative query OR something

Oops... that is:

(-fname:*) OR fname:(A B C)

or

(-fname:[* TO *]) OR fname:(A B C)

-- Jack Krupansky

-----Original Message----- From: Jack Krupansky
Sent: Wednesday, May 02, 2012 7:48 PM
To: solr-user@lucene.apache.org
Subject: Re: syntax for negative query OR something

Sounds good. "OR" in the negation of any query that matches any possible
value in a field.

The Solr query parser doc lists the open range as you used:

     -field:[* TO *] finds all documents without a value for field

See:
http://wiki.apache.org/solr/SolrQuerySyntax

This also include pure wildcard that can generate a PrefixQuery:

      -fname:* OR fname:(A B C)


-- Jack Krupansky

-----Original Message----- From: Ryan McKinley
Sent: Wednesday, May 02, 2012 7:18 PM
To: solr-user@lucene.apache.org
Subject: syntax for negative query OR something

How do I search for things that have no value or a specified value?

Essentially I have a field that *may* exist and what the absense of a
field to also match.

I have a few variations of:
-fname:[* TO *] OR fname:(A B C)


Thanks for any pointers

ryan

Reply via email to