如何在 solr 中进行布尔或运算?
我对此完全陌生......
我正在将 durpal 与 apachesolr 模块一起使用。
我有以下过滤器:
( tid:19895 OR tid:19937 ) AND type:poster"
This does not return any results, but if I have the following, it returns the results as expected( tid:19937 ) AND type:poster"
EDIT: This is all in a filter. I need to have a list of tids that it could be along with having type be poster. So it has to be type:poster AND one of the following tids: 19895, 19937I am completely new at this...
I am using durpal with the apachesolr module.
I have the following filter:
( tid:19895 OR tid:19937 ) AND type:poster"
This does not return any results, but if I have the following, it returns the results as expected
( tid:19937 ) AND type:poster"
EDIT: This is all in a filter. I need to have a list of tids that it could be along with having type be poster. So it has to be type:poster AND one of the following tids: 19895, 19937
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然:
((tid:(19895 OR 19937)) AND type:poster) 应该可以工作,无论 defaultOperator 是 OR/AND
添加子句作为单独的过滤器更好,因此添加两个过滤器作为
tid:(19895 OR 19937)
type:poster
应过滤掉作为 AND 工作的结果,并单独缓存此过滤器的结果,以提高使用此过滤器的新查询的查询性能。
although:
((tid:(19895 OR 19937)) AND type:poster) should work irrespective of defaultOperator being OR/AND
adding the clauses as separate filter is better, so add two filters as
tid:(19895 OR 19937)
type:poster
should filter out the results working as AND and also cache the results for this filter separately for improved query performance for new queries using this filter.
我认为值得注意的是 SOLR 不是数据库。它是一个搜索引擎,因此不会像您可能习惯的数据库查询那样工作。
添加 + 表示该字段是必需的。
* 是通配符,因此添加它意味着您的字段将包含该值,但不一定等于该值。
看起来问题是在同一个过滤器中两次定义该字段???
所以尝试删除第二个“tid:”
在我的测试中我这样做了:
我的 SOLR 查询是:
过滤器是:
这是另一个与您类似的 stackoverflow 问题,因为您的语法显然与我使用的不同。
在 solr 查询中使用 OR 和 NOT
I think its important to note that SOLR isn't a database. Its a search engine and therefore isn't going to work like a database query you may be used to.
adding a + means the field is required
The * is the wildcard so adding it means your field would contain the value but not necessarily equal the value.
It looks like the issue is defining the field twice in the same filter???
So try removing the second "tid:"
In my testing I did this:
My SOLR query is:
And the Filter is:
Here is another stackoverflow question similar to yours since you obviously have a different syntax than I use.
using OR and NOT in solr query
仅供参考,如果默认布尔子句是“OR”,则给出如下查询
((tid:(19895 19937)) AND type:poster) 我测试过这个工作正常
As FYI if defalut boolen clause is "OR" then give the query like this
((tid:(19895 19937)) AND type:poster) This working fine i tested