Solr 部分搜索,奇怪的行为
Solr partial search, strange behaviour
我对 Solr 部分搜索有奇怪的行为。我使用这个过滤器:
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" />
我使用了不同的版本:Solr 4 和 Solr 5。
我有下一个匹配结果:
1) 词:通知
Not - YES
Noti - YES
Notif - YES
Notifi - NO
Notific - YES
Notifica - NO
Notificat - NO
Notificati - NO
Notificatio - NO
Notification - YES
Notifications - YES
2) 两个词:A - 乘法和 B - 乘法(错误)
Mul: A - YES, B - YES
Mult: A - YES, B - YES
Multi: A - YES, B - YES
Multip: A - YES, B - YES
Multipl: A - YES, B - YES
Multipli: A - NO, B - YES
Multiplic: A - YES, B - YES
Multiplica: A - NO, B - YES
Multiplicat: A - NO, B - YES
Multiplicati: A - NO, B - YES
Multiplicatin: A - NO, B - YES
Multiplicatina: A - NO, B - NO
Multiplicatinat: A - NO, B - NO
Multiplicatinati: A - NO, B - NO
Multiplicatinatio: A - NO, B - NO
Multiplicatination: A - NO, B - YES
Multiplicatio: A - NO, B - NO
Multiplication: A - YES, B - YES (!!!)
为什么它以如此奇怪的方式工作?我该如何解决?
为什么 "Notific" 匹配 "Notifications",而 "Notifi"、"Notifica" 和 "Notificatio" 不匹配?
为什么 "Multiplica" 匹配 "Multiplicatination",但不匹配 "Multiplication"?
为什么 "Multiplication" 与 "Multiplicatination" 匹配?
它是如何工作的?
我运行下一个查询(我从调试器中获取):
/select?q="multiplic"&fq=(ss_search_api_datasource%3A"entity%3Anode"+ss_media_bundle%3A"document")&fq=(ss_search_api_datasource%3A"entity%3Amedia"+ss_node_bundle%3A"task"+ss_node_bundle%3A"supply"+ss_node_bundle%3A"store"+ss_node_bundle%3A"news"+ss_node_bundle%3A"faq")&fq=index_id%3A"search"&fq=hash%3A"8qk984"&rows=3&fl=ss_search_api_id%2Cscore&wt=json&indent=true&defType=edismax&qf=tm_attachment_file%5E1+ts_media_name%5E8+ts_media_file_name%5E2+ts_node_title%5E13+ts_node_body%5E3&stopwords=true&lowercaseOperators=true
为 Solr 5 使用了 schema.xml 中的字段定义:
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<!-- Case insensitive stop word removal. -->
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory"
protected="protwords.txt"
generateWordParts="1"
generateNumberParts="1"
catenateWords="1"
catenateNumbers="1"
catenateAll="0"
splitOnCaseChange="0"
preserveOriginal="1"/>
<filter class="solr.LengthFilterFactory" min="2" max="100" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" />
</analyzer>
<analyzer type="query">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory"
protected="protwords.txt"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
splitOnCaseChange="0"
preserveOriginal="1"/>
<filter class="solr.LengthFilterFactory" min="2" max="100" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="multiterm">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory"
protected="protwords.txt"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
splitOnCaseChange="1"
preserveOriginal="1"/>
<filter class="solr.LengthFilterFactory" min="2" max="100" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
我认为 SnowballPorterFilterFactory
造成了问题。你能通过从索引分析器中删除它来检查它吗?
您可以找到更多相关信息Here
我对 Solr 部分搜索有奇怪的行为。我使用这个过滤器:
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" />
我使用了不同的版本:Solr 4 和 Solr 5。 我有下一个匹配结果: 1) 词:通知
Not - YES
Noti - YES
Notif - YES
Notifi - NO
Notific - YES
Notifica - NO
Notificat - NO
Notificati - NO
Notificatio - NO
Notification - YES
Notifications - YES
2) 两个词:A - 乘法和 B - 乘法(错误)
Mul: A - YES, B - YES
Mult: A - YES, B - YES
Multi: A - YES, B - YES
Multip: A - YES, B - YES
Multipl: A - YES, B - YES
Multipli: A - NO, B - YES
Multiplic: A - YES, B - YES
Multiplica: A - NO, B - YES
Multiplicat: A - NO, B - YES
Multiplicati: A - NO, B - YES
Multiplicatin: A - NO, B - YES
Multiplicatina: A - NO, B - NO
Multiplicatinat: A - NO, B - NO
Multiplicatinati: A - NO, B - NO
Multiplicatinatio: A - NO, B - NO
Multiplicatination: A - NO, B - YES
Multiplicatio: A - NO, B - NO
Multiplication: A - YES, B - YES (!!!)
为什么它以如此奇怪的方式工作?我该如何解决?
为什么 "Notific" 匹配 "Notifications",而 "Notifi"、"Notifica" 和 "Notificatio" 不匹配? 为什么 "Multiplica" 匹配 "Multiplicatination",但不匹配 "Multiplication"? 为什么 "Multiplication" 与 "Multiplicatination" 匹配? 它是如何工作的?
我运行下一个查询(我从调试器中获取):
/select?q="multiplic"&fq=(ss_search_api_datasource%3A"entity%3Anode"+ss_media_bundle%3A"document")&fq=(ss_search_api_datasource%3A"entity%3Amedia"+ss_node_bundle%3A"task"+ss_node_bundle%3A"supply"+ss_node_bundle%3A"store"+ss_node_bundle%3A"news"+ss_node_bundle%3A"faq")&fq=index_id%3A"search"&fq=hash%3A"8qk984"&rows=3&fl=ss_search_api_id%2Cscore&wt=json&indent=true&defType=edismax&qf=tm_attachment_file%5E1+ts_media_name%5E8+ts_media_file_name%5E2+ts_node_title%5E13+ts_node_body%5E3&stopwords=true&lowercaseOperators=true
为 Solr 5 使用了 schema.xml 中的字段定义:
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<!-- Case insensitive stop word removal. -->
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory"
protected="protwords.txt"
generateWordParts="1"
generateNumberParts="1"
catenateWords="1"
catenateNumbers="1"
catenateAll="0"
splitOnCaseChange="0"
preserveOriginal="1"/>
<filter class="solr.LengthFilterFactory" min="2" max="100" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" />
</analyzer>
<analyzer type="query">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory"
protected="protwords.txt"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
splitOnCaseChange="0"
preserveOriginal="1"/>
<filter class="solr.LengthFilterFactory" min="2" max="100" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="multiterm">
<charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
/>
<filter class="solr.WordDelimiterFilterFactory"
protected="protwords.txt"
generateWordParts="1"
generateNumberParts="1"
catenateWords="0"
catenateNumbers="0"
catenateAll="0"
splitOnCaseChange="1"
preserveOriginal="1"/>
<filter class="solr.LengthFilterFactory" min="2" max="100" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
我认为 SnowballPorterFilterFactory
造成了问题。你能通过从索引分析器中删除它来检查它吗?
您可以找到更多相关信息Here