如何在 solr 中进行布尔或运算?

发布于 2024-11-19 12:17:11 字数 496 浏览 0 评论 0原文

我对此完全陌生......

我正在将 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, 19937

I 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江南月 2024-11-26 12:17:11

虽然:

((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.

终弃我 2024-11-26 12:17:11

我认为值得注意的是 SOLR 不是数据库。它是一个搜索引擎,因此不会像您可能习惯的数据库查询那样工作。

添加 + 表示该字段是必需的。

+tid:19895 would mean that TID field is required to equal exactly 19895

* 是通配符,因此添加它意味着您的字段将包含该值,但不一定等于该值。

tid:19895* would mean TID field contains 19895

看起来问题是在同一个过滤器中两次定义该字段???

所以尝试删除第二个“tid:”

在我的测试中我这样做了:
我的 SOLR 查询是:

+type:poster

过滤器是:

tid:19895 OR 19937

这是另一个与您类似的 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

+tid:19895 would mean that TID field is required to equal exactly 19895

The * is the wildcard so adding it means your field would contain the value but not necessarily equal the value.

tid:19895* would mean TID field contains 19895

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:

+type:poster

And the Filter is:

tid:19895 OR 19937

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

乄_柒ぐ汐 2024-11-26 12:17:11

仅供参考,如果默认布尔子句是“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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文