The q.op
parameter gives us the opportunity to choose what kind of boolean operator should be used in the query. It is generally preferable to choose an OR
behavior, because it is more intuitive to reflect user expectations, and AND
will act as a filter:
q.op
in an explicit way.>> curl -G 'http://localhost:8983/solr/paintings/select?rows=0&wt=json' --data-urlencode 'q={!lucene q.op=OR}dali christ'
The command gives the following output:
{"responseHeader":{"status":0,"QTime":5},"response" {"numFound":155,"start":0,"docs":[]}}
AND
operator instead.>> curl -G 'http://localhost:8983/solr/paintings/select?rows=0&wt=json' --data-urlencode 'q={!lucene q.op=AND}dali christ'
The output obtained is as follows:
{"responseHeader":{"status":0,"QTime":5},"response":{"numFound":4,"start":0,"docs":[]}}
As expected, it returns less results. Notice that in this case we deliberately omit the documents returned with value of rows as 0.
In these examples, we saw how simple it is to use different values for the q.op
parameter. Since these parameters control the default way in which a collection of terms are combined for a search, this should be used carefully. Also, you should not expect it to change its default value unless you have a very particular case. For example, if we had a request for using restrictive search keywords since the AND
operator allows the addition of a filter for every term.
3.133.116.137