Solr能精准搜索关键词吗?

发布于 2024-12-17 18:22:08 字数 108 浏览 0 评论 0原文

例如: 我想搜索“support”,我希望它只返回包含“support”的结果,而不返回包含“supports”或任何其他相关匹配项的结果。

这样的实现可以吗?

谢谢。

For example:
I want to search "support", I hope it will only return the results containing "support", and do NOT return the result containing "supports" or any other relevant matches.

Is it possible to implement like this?

Thanks.

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

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

发布评论

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

评论(2

清欢 2024-12-24 18:22:08

是的,如果您搜索未分析的字段类型,则匹配是精确的。在默认的 Solr 模式中,未分析的字段类型被命名为“string”(属于“solr.StrField”类)

​​编辑:这取决于“精确”的含义。如果您的字段值是“支持台”并且您的查询是“支持”,它应该匹配吗?

  • 如果您的答案是肯定的,那么您应该考虑配置词干提取。
  • 如果您的答案是否定的,即查询必须与字段值匹配而没有其他内容,那么您应该使用字符串(即未分析)字段类型。

此外,如果您的查询是“supports”并且字段值为“Supports”,它应该匹配吗?

  • 如果您回答“是”,那么您应该使用 LowerCaseFilterFactory(您不能在字符串字段类型上执行此操作,您必须切换到文本字段类型)。
  • 如果您回答否,那么使用字符串字段类型就可以了。

总之,Lucene/Solr 文本分析管道是非常可配置的,请查看分析器文档以供所有参考可用选项。

Yes, if you search against an unanalyzed field type, matches are exact. In the default Solr schema the unanalyzed field type is named "string" (of class "solr.StrField")

EDIT: it depends on what you mean by "precisely". If your field value is "support desk" and your query is "support", should it match?

  • If your answer is yes, then you should look into configuring stemming.
  • If your answer is no, i.e. the query must match the field value and nothing else, then you should use a string (i.e. unanalyzed) field type.

Furthermore, if your query is "supports" and the field value is "Supports", should it match?

  • If you answer yes, then you should use a LowerCaseFilterFactory (you can't do this on a string field type, you'll have to switch to a text field type).
  • If you answer no, then it's ok to use a string field type.

In summary, the Lucene/Solr text analysis pipeline is very configurable, take a look at the analyzer docs for a reference of all available options.

も星光 2024-12-24 18:22:08

您所描述的称为词干。关于堆栈溢出还有另一个几乎相同的问题,请查看:Solr 精确单词搜索
您将需要在配置中重新索引并禁用词干提取。我不认为在查询时可以做到这一点,因为存储在索引中的是单词的词干版本。在您的情况下,即使显示“支持”,“支持”也存储在索引中。
这应该可以帮助您开始如何在 Solr 中配置词干分析?

What you are describing is called stemming. There is another almost identical question on stack overflow, check it out : Solr exact word search
You will need to re-index and disable stemming in your configuration. I don't believe it's possible to do that at query time since what is stored in your index is the stemmed version of the word. In your case "support" is stored in the index even is "supports" is displayed.
This should get you started How to configure stemming in Solr?

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