最近我从 solr 4 迁移到 6。
在 solr 4shinglefilterfactory
中工作正常,我的配置是
<fieldType name="text_shingle" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="5"
outputUnigrams="false" outputUnigramsIfNoShingles="false" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="5"
outputUnigrams="false" outputUnigramsIfNoShingles="false" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PositionFilterFactory"/>
</analyzer>
</fieldType>
但是在更新到 solr 6 shingles 后无法正常工作,架构如下,
<fieldType name="text_shingle" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="5"
outputUnigrams="false" outputUnigramsIfNoShingles="false" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="5"
outputUnigrams="false" outputUnigramsIfNoShingles="false" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
尽管在“分析”选项卡中显示了正确的 shingle 结果,但是在 queryParser 中使用时却没有给出正确的结果
我的样本命中是
http://localhost:8983/solr/shingel_test/select?q=one%20plus%20one&wt=xml&debugQuery=true&defType=edismax&qf=cust_shingle
它将解析的查询创建为:
<str name="rawquerystring">one plus one</str>
<str name="querystring">one plus one</str>
<str name="parsedquery">(+())/no_coord</str>
<str name="parsedquery_toString">+()</str>
<lst name="explain"/>
<str name="QParser">ExtendedDismaxQParser</str>