Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to select multiple values in solr via the query string?

Tags:

solr

let's say for example i need to search for a number of ids, and by looking at the solr/admin page, at the "Make a Query" input form, there is a

*:* 

how am I gonna search a multiple value if it only works with one query whenever I fire the search button ?

I tried

id:123,413,2232,2323

it didn't work..but this single query, works

id:123
like image 911
sasori Avatar asked Jan 30 '13 02:01

sasori


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 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). Follow this answer to receive notifications.

What is WT in solr?

Solr supports a variety of Response Writers to ensure that query responses can be parsed by the appropriate language or application. The wt parameter selects the Response Writer to be used. The table below lists the most common settings for the wt parameter.

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 .


3 Answers

Solr automatically uses OR as an operator, so the shortest version would be:

id:(123 413 2232 2323)
like image 169
P.Albrecht Avatar answered Oct 23 '22 06:10

P.Albrecht


Please check out the SolrQuerySyntax page on the Solr wiki for some examples of the query syntax for Solr.

Given your example you could query for this in a couple of ways:

  1. id:[1 TO 4]
  2. (id:1 OR id:2 OR id:3 OR id:4)
like image 34
Paige Cook Avatar answered Oct 23 '22 07:10

Paige Cook


I would slightly modify second option to be:

id:(ONE OR TWO OR THREE) 
like image 44
Kris79 Avatar answered Oct 23 '22 07:10

Kris79