【问题标题】:Solr 4.4: StopFilterFactory and enablePositionIncrementsSolr 4.4:StopFilterFactory 和 enablePositionIncrements
【发布时间】:2013-09-07 00:13:19
【问题描述】:

在尝试从 Solr 4.3.0 升级到 Solr 4.4.0 时,我遇到了这个异常:

 java.lang.IllegalArgumentException: enablePositionIncrements=false is not supported anymore as of Lucene 4.4 as it can create broken token streams

这让我找到了this issue。我需要能够匹配查询,而不管插入的停用词(曾经与 enablePositionIncrements="true" 一起使用)。例如:“foo of the bar”会找到匹配“foo bar”、“foo of bar”和“foo of the bar”的文档。在 4.4.0 中不推荐使用此选项后,我不清楚如何维护相同的功能。

package javadoc 补充道:

如果选择的分析器过滤了停用词“is”和“the”,那么对于包含字符串“blue is the sky”的文档,只有标记“blue”、“sky”被索引,位置(“天空") = 3 + 位置("蓝色")。现在,短语查询“blue is the sky”会找到该文档,因为相同的分析器会从该查询中过滤相同的停用词。但是短语查询“blue sky”不会找到该文档,因为“blue”和“sky”之间的位置增量仅为 1。

如果此行为不符合应用程序的需要,则需要将查询解析器配置为在生成短语查询时不考虑位置增量。

但没有提及如何实际配置查询解析器来执行此操作。随着 Solr 迈向 5.0,有谁知道如何处理这个问题?

【问题讨论】:

  • 你找到解决这个问题的方法了吗?
  • @VishalParekh nope - 还没有找到解决方案...
  • @condit 我有同样的问题,我正在考虑重新实现StopFilterFactory 并重新启用将enablePositionIncrements 设置为false 的选项
  • @condit,我面临同样的问题。有什么解决办法吗?
  • @MMTac - 不。仍然坚持这一点。

标签: solr lucene solr4


【解决方案1】:

您可以使用邻近搜索:

"foo bar"~2

【讨论】:

  • 这没有提供问题的答案。要批评或要求作者澄清,请在其帖子下方发表评论。
  • 删除了反问:)
【解决方案2】:

不知道这个是否推荐使用,不过Lucene 5中还有一些遗留类,比如Lucene43StopFilter

不幸的是,它们似乎在 Lucene 6 中消失了......

【讨论】:

    【解决方案3】:

    我在某个地方找到了 RemoveTokenGapsFilterFactory 的网络实现

    public final class RemoveTokenGapsFilter extends TokenFilter {
    
        private final PositionIncrementAttribute posIncrAttribute = addAttribute(PositionIncrementAttribute.class);
    
        public RemoveTokenGapsFilter(TokenStream input) {
            super(input);
        }
    
        @Override
        public boolean incrementToken() throws IOException {
    
            if (input.incrementToken()) {
                posIncrAttribute.setPositionIncrement(1);
                return true;
            }
    
            return false;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-05-31
      • 2013-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多