简体   繁体   中英

How to do an IN query in 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. Eg 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')

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)

The above solution did not work for me. But this syntax did

column_name:+(value1 value2)

http://harmssite.com/2012/09/solr-query-for-mimicking-sql-in-operator-functionality/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM