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

4

15

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
Baumgardner answered 30/1, 2013 at 2:36 Comment(0)
K
22

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)
Kumiss answered 30/1, 2013 at 2:56 Comment(2)
what if the values are different and it can't be in range like that in your example as id:[1 TO 4] ...and the default operator is AND not OR, what to do ?Baumgardner
Modified second option to show how to force the OR to occur no matter what the default operator is set to.Kumiss
A
30

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

id:(123 413 2232 2323)
Amandaamandi answered 30/8, 2016 at 12:59 Comment(0)
K
22

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)
Kumiss answered 30/1, 2013 at 2:56 Comment(2)
what if the values are different and it can't be in range like that in your example as id:[1 TO 4] ...and the default operator is AND not OR, what to do ?Baumgardner
Modified second option to show how to force the OR to occur no matter what the default operator is set to.Kumiss
T
12

I would slightly modify second option to be:

id:(ONE OR TWO OR THREE) 
Tanagra answered 30/12, 2014 at 15:57 Comment(0)
F
0

There are only two ways you can achieve it:

  1. id: 123 OR id:413 OR id:2232 OR id:2323

  2. id:(123 413 2232 2323)

Both are the same the second one is a shorthand.

Foreleg answered 6/8, 2021 at 6:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.