在 Solr 中搜索确切短语时,是否可以包含停用词? [英] Is there a way to include stopwords when searching exact phrases in Solr?

查看:42
本文介绍了在 Solr 中搜索确切短语时,是否可以包含停用词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想排除停用词,除非搜索词在双引号内

I want stopwords excluded except when the search term is within double quotes

例如.就像那样"也应该搜索那样".

eg. "just like that" should also search "that".

这可能吗?

推荐答案

这取决于你查询的字段的配置.

It depends on the configuration of the field you are querying.

如果索引分析器的配置包含一个StopFilterFactory,那么停用词根本就没有被索引,因此您之后无法查询它们.但是由于 Solr 保留了词条在索引中的位置,您可以指示它增加剩余词条的位置值,以反映原来中间还有其他词条的事实.

If the configuration of the indexing analyzer includes a StopFilterFactory, then the stopwords are simply not indexed, so you can not query for them afterward. But since Solr keeps the position of the terms in the index, you can instruct it to increment the position value of the remaining terms to reflect the fact that originally, there was other terms in between.

这里的enablePositionIncrements"是实现这一目标的关键:

The "enablePositionIncrements" here is the key to achieve that:

<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>

如果查询分析器也有使用相同设置配置的 StopFilterFactory,您的查询应该按预期工作.

If the querying analyzer also has the StopFilterFactory configured with the same settings, your query should work as expected.

查看此链接了解详情:http://www.lucidimagination.com/search/document/CDRG_ch05_5.6.18

这篇关于在 Solr 中搜索确切短语时,是否可以包含停用词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆