How to do an IN query in Solr?
i'm having documents with a multivalued field "sharedTo" which contains the groups that the doc开发者_如何学运维ument 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')
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)
If you're using SolrJ as client your query would look like as follows:
fq=sharedTo:("foo" OR "bar")
Hope this helps
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/
精彩评论