Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do an IN query in Solr?

Tags:

syntax

solr

i'm having documents with a multivalued field "sharedTo" which contains the groups that the document is shared to. Now I want to find all documents that are shared to at least one of a list of given groups. E.g. I want to find all documents that are shared to the group "foo" or the group "bar" or both. Currently I'm building a query like this:

sharedTo:"foo" OR sharedTo:"bar" 

For each group I just add a new OR query part. This works, however I wonder if there is a more efficient way of doing this like a

sharedTo IN ('foo', 'bar') 
like image 953
Jan Thomä Avatar asked May 11 '11 07:05

Jan Thomä


People also ask

How do I query in solr collection?

You can search for "solr" by loading the Admin UI Query tab, enter "solr" in the q param (replacing *:* , which matches all documents), and "Execute Query". See the Searching section below for more information. To index your own data, re-run the directory indexing command pointed to your own directory of documents.

What is FL in solr query?

The fl parameter limits the information included in a query response to a specified list of fields. The fields need to either be stored="true" or docValues="true"` . ` The field list can be specified as a space-separated or comma-separated list of field names.

What is DF in solr query?

The df stands for default field , while the qf stands for query fields . The field defined by the df parameter is used when no fields are mentioned in the query. For example if you are running a query like q=solr and you have df=title the query itself will actually be title:solr .

What is the difference between Q and FQ in solr?

Standard solr queries use the "q" parameter in a request. Filter queries use the "fq" parameter. The primary difference is that filtered queries do not affect relevance scores; the query functions purely as a filter (docset intersection, essentially).


1 Answers

if your default operator is OR, then you can just give the query as

sharedTo:('foo' 'bar')

If your default operator is AND, then you'll have to do it like this: sharedTo:(foo OR bar)

like image 192
Umar Avatar answered Sep 21 '22 16:09

Umar