Lucene 过滤器和“AND”操作员

发布于 2024-09-28 11:21:53 字数 867 浏览 2 评论 0原文

我正在构建一个电子商务搜索,并使用 Lucene.Net 作为我的搜索引擎。不过,我在过滤查询时遇到了麻烦。

这是我索引的文档之一,具有以下字段和值:
字段:“名称”,值:“Mochila MVP”
字段:“制造商”,值:“耐克配件”

现在,当我运行这些搜索时,我得到以下结果:

用户输入的查询:
莫奇拉^5 耐克^2.5
Lucene 将其翻译为:
(((名称:mochil 制造商:mochil)^5.0) ((名称:nik 制造商:nik)^2.5))
结果:
带来产品“Mochila MVP”

用户输入的查询:
mochila^5 和耐克^2.5
Lucene 将其翻译为:
(+((名称:mochil 制造商:mochil)^5.0) +((名称:nik 制造商:nik)^2.5))
结果:
没有结果

用户输入的查询:
mochila^5 +制造商:耐克
Lucene 将其翻译为:
((名称:mochil)^5.0) +制造商:耐克
结果:
没有结果

我想知道为什么第二个和第三个查询没有结果,因为它们似乎与我的产品名称和制造商相匹配......

非常感谢任何帮助。提前致谢!

I'm building an e-commerce search and I am using Lucene.Net as my search engine. I am having trouble filtering my queries, though.

This is one of the documents I have indexed, with the following fields and values:

field: "name", value: "Mochila MVP"

field: "manufacturer", value: "Nike Accessories"

Now, when I run these searches I have the folowing results:

User typed query:

mochila^5 nike^2.5

Lucene translated it to:

(((name:mochil manufacturer:mochil)^5.0) ((name:nik manufacturer:nik)^2.5))

Results:

Brings the product "Mochila MVP"

User typed query:

mochila^5 AND nike^2.5

Lucene translated it to:

(+((name:mochil manufacturer:mochil)^5.0) +((name:nik manufacturer:nik)^2.5))

Results:

No results

User typed query:

mochila^5 +manufacturer:nike

Lucene translated it to:

((name:mochil)^5.0) +manufacturer:nike

Results:

No results

What I would like to know is why the second and third queries bring no results, because they seem to match the product's name and manufacturer to me...

Any help is highly appreciated. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

緦唸λ蓇 2024-10-05 11:21:53

造成这种[意外]结果的可能原因有很多。以下内容可能会帮助您解决此问题:

  • 如何构建索引?
    • 分析器很重要
    • 哪些字段实际被索引(分析)。我猜想“manufacturer”可能不会被分析 - 请注意,您的第一个查询会在所有字段中搜索这两个术语(即表现得像“catch all”)
  • Luke 并查看索引中的内容
  • 另请注意,当您使用“AND”或“+”时,这实际上意味着“并且这些术语必须”出现在该字段中”(即此类查询比您的第一个查询更严格)

There are a lot of possible reasons why you get such [unexpected] results. Here's what might help you in resolving this issue:

  • How do you build your index?
    • analyzer matters
    • which fields are actually indexed (analyzed). I guess that 'manufacturer' might not be analyzed - note that your first query searches for both terms in all the fields (i.e. is acting like 'catch all')
  • Take Luke and see what's inside your index
  • Also note that when you use 'AND' or '+' this actually means 'and these terms must be present in this field' (i.e. such queries are stricter than your first one)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文