如何在 Solr 中进行 IN 查询? [英] How to do an IN query in Solr?
问题描述
我有一个多值字段sharedTo"的文档,其中包含文档共享到的组.现在我想找到至少与给定组列表中的一个共享的所有文档.例如.我想找到共享给组foo"或组bar"或两者的所有文档.目前我正在构建这样的查询:
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"
对于每个组,我只添加一个新的 OR 查询部分.这是有效的,但是我想知道是否有更有效的方法来做到这一点
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')
推荐答案
如果您的默认运算符是 OR,那么您可以将查询设为
if your default operator is OR, then you can just give the query as
sharedTo:('foo' 'bar')
如果您的默认运算符是 AND,那么您必须这样做:sharedTo:(foo OR bar)
If your default operator is AND, then you'll have to do it like this: sharedTo:(foo OR bar)
这篇关于如何在 Solr 中进行 IN 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!