How to specify an OR value in an Apache Solr request?

The last way to solve this for me is to ask StackOverflow.

I am trying to create a Solr request to get documents that have a specific value in one of their fields, or that does not matter ...

Theoretically, this request should work.

Here is some info:

Query: (name: john) β†’ Number of results: 15383 // Johns

Query: (name: {* TO *}) β†’ Number of results: 61013 // People who have a name

Request: - (name: {* TO *}) β†’ Result counter: 216888 // People who do not have a name

Now, when I use the first and third query in the same query with the OR operator, I expect to get the results (216888 + 15383). But SOLR gives the results of 15383, it simply ignores the effect of the third query:

Request: + ((name: john) (- (name: {* TO *}))) // This is the request I used.

Is this a Solr error or am I mistaken in the request? Combining the two query results is an additional solution, but I don’t want to do additional implementation of the code if I could do it with a simple query.

Any help would be appreciated.

+10
solr result sql-null
source share
3 answers

(-name:[* TO *] AND *:*) OR name:john

+20
source share

You can also use it like this.

 &fq=name:john OR !name:['' TO *] 
+1
source share

try the following query -

 q=(name:john OR -(name:[* TO *])) 
-one
source share

All Articles