Solr中不一致的突出显示

时间:2013-11-28 08:18:13

标签: apache solr

我使用Solr索引数据。我想在搜索结果中突出显示匹配的关键字。突出显示是不一致的 例如。如果搜索关键字是'alonso'。

突出显示的实例是: 的阿隆索下,fernando_的阿龙下,*的 #Alonso * MeetVettel

非highlightes实例是: @fernandoalonso,www.alonsodriver.com

谁能告诉我为什么会这样?

我正在使用此配置 -

  <fieldType name="text" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
  </analyzer>
</fieldType>

1 个答案:

答案 0 :(得分:0)

使用WhitespaceTokenizerFactory和WordDelimiterFilterFactory,单词将在空白和下划线上拆分,然后进行搜索。这个TokenizerFactory就像fernandoalonso这样的单词不会以相同的方式分割。为了获得关于fernandoalon的点击和亮点,你必须使用ngrams将整个单词变成许多较小的单词,这些单词是该单词的一部分。像nso,onso,lonso,alonso。

可以在Apache solr search part of the word

找到包括使用ngrams的好答案
相关问题