0

这是我的查询分析器定义:

<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="companysyns.txt" ignoreCase="true" expand="true"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>

在“companysyncs.txt”中,我对典型的公司词进行了一些扩展,如下所示:

inc, inc., incorporated

当我发送这样的查询时:

test:"some company inc"

我在 solr 调试中看到了这个意想不到的结果:

<str name="rawquerystring">test:"some company inc"</str>
<str name="querystring">test:"some company inc"</str>
<str name="parsedquery">
MultiPhraseQuery(test:"some company inc (inc incorporated)")
</str>
<str name="parsedquery_toString">test:"some company inc (inc incorporated)"</str>

与“Some Company, Inc.”不匹配。但是,如果我删除WordDelimiterFilterFactory, 那么对于相同的查询,我会看到:

<str name="rawquerystring">test:"some company inc"</str>
<str name="querystring">test:"some company inc"</str>
<str name="parsedquery">
MultiPhraseQuery(test:"some company (inc inc. incorporated)")
</str>
<str name="parsedquery_toString">test:"some company (inc inc. incorporated)"</str>

这确实匹配。

如果我保留WordDelimiterFilterFactory,但删除“inc”。来自同义词的条目(带有句点的那个),那么它也可以:

<str name="rawquerystring">test:"some company inc"</str>
<str name="querystring">test:"some company inc"</str>
<str name="parsedquery">
MultiPhraseQuery(test:"some company (inc incorporated)")
</str>
<str name="parsedquery_toString">test:"some company (inc incorporated)"</str>

知道为什么WordDelimiterFilterFactory要搞乱同义词扩展查询吗?

谢谢!

4

1 回答 1

0

WordDelimiterFilterFactory 删除 inc 中的点。更改过滤器的顺序,它应该可以正常工作:

    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.SynonymFilterFactory" synonyms="companysyns.txt" ignoreCase="true" expand="true"/>
于 2012-04-19T13:29:44.520 回答