2016-07-28 132 views
0

我正在使用Solr。 我需要搜索那些提供的關鍵字 的功能應該類似於SQL查詢等%關鍵字%匹配條目 MY類型的文件:text_en 我使用,則提取數據如Facebook(這是正確的) 此外,我還提取關鍵字 像「面臨」(這是不正確的)。solr像使用text_en搜索

我的想法是讓喜歡「面對%%」

我將如何做到這一切的關鍵字? 即時通訊使用SOLR 4.4 我Solr模式低於:

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100"> 
     <analyzer type="index"> 
     <tokenizer class="solr.StandardTokenizerFactory"/> 
     <!-- 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="lang/stopwords_en.txt" 
       /> 
     <filter class="solr.LowerCaseFilterFactory"/> 
    <filter class="solr.EnglishPossessiveFilterFactory"/> 
     <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> 
    <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory: 
     <filter class="solr.EnglishMinimalStemFilterFactory"/> 
    --> 
     <filter class="solr.PorterStemFilterFactory"/> 
     </analyzer> 
     <analyzer type="query"> 
     <tokenizer class="solr.StandardTokenizerFactory"/> 
     <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> 
     <filter class="solr.StopFilterFactory" 
       ignoreCase="true" 
       words="lang/stopwords_en.txt" 
       /> 
     <filter class="solr.LowerCaseFilterFactory"/> 
    <filter class="solr.EnglishPossessiveFilterFactory"/> 
     <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> 
    <!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory: 
     <filter class="solr.EnglishMinimalStemFilterFactory"/> 
    --> 
     <filter class="solr.PorterStemFilterFactory"/> 
     </analyzer> 
    </fieldType> 

回答

1

,應禁用詞幹如果你不想匹配「面對」。

相反,你可以使用EdgeNGramFilterFactory單詞的索引子

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