如何在 Solr 中进行 IN 查询?
我的文档具有多值字段“sharedTo”,其中包含文档共享到的组。现在我想查找至少与给定组列表之一共享的所有文档。例如,我想查找共享给“foo”组或“bar”组或两者共享的所有文档。目前,我正在构建这样的查询:
sharedTo:"foo" OR sharedTo:"bar"
对于每个组,我只需添加一个新的 OR 查询部分。这是可行的,但是我想知道是否有一种更有效的方法可以做到这一点,例如
sharedTo IN ('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"
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')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的默认运算符是 OR,那么您只需将查询指定为
sharedTo:('foo' 'bar')
如果您的默认运算符是 AND,那么您必须这样做: sharedTo:(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)
如果您使用 SolrJ 作为客户端,您的查询将如下所示:
希望这有帮助
If you're using SolrJ as client your query would look like as follows:
Hope this helps
上述解决方案对我不起作用。但这种语法确实是
column_name:+(value1 value2)
http://harmssite.com/2012/09/solr-query-for-mimicking-sql-in-operator-functionity/
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/