Solr部分搜索,奇怪的行为

时间:2017-05-30 14:59:10

标签: search solr partial

我有Solr部分搜索的奇怪行为。我使用这个过滤器:

<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" />

我使用了不同的版本:Solr 4和Solr 5。 我有下一个匹配的结果: 1)Word:通知

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”匹配,但不与“Multiplica”匹配? 为什么“乘法”与“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

来自schema.xml的Solr 5的使用字段定义:

<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>

1 个答案:

答案 0 :(得分:1)

我认为SnowballPorterFilterFactory正在制造问题。你可以通过从索引分析器中删除它来检查它。

您可以找到有关它的更多信息Here