【问题标题】:Is there a way to include stopwords when searching exact phrases in Solr?在 Solr 中搜索确切的短语时,有没有办法包含停用词?
【发布时间】:2011-02-10 12:05:12
【问题描述】:

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

例如。 “just like that”也应该搜索“that”。

这可能吗?

【问题讨论】:

    标签: search solr


    【解决方案1】:

    这取决于您要查询的字段的配置。

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

    这里的“enablePositionIncrements”是实现这一点的关键:

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

    如果查询分析器也使用相同的设置配置了 StopFilterFactory,那么您的查询应该会按预期工作。

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

    【讨论】:

    • 很难找到 enablePositionIncrements 属性的确切定义。谢谢老兄!
    • 已弃用:如果 luceneMatchVersion 为 5.0 或更高版本,则此参数无效lucene.apache.org/solr/guide/6_6/…
    【解决方案2】:

    我还很幸运地使用CommonGramsFilterFactory 将它放在您的 fieldType 声明中的适当位置来获得类似的结果。

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

    不确定在 StopFilterFactory 中启用 enablePositionIncrements="true" 的效果如何。您还需要运行 solr 1.4 才能使用它。

    【讨论】:

    • 非常感谢,知道了很有用
    猜你喜欢
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 2015-12-25
    • 2014-02-05
    • 2013-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多