簡體   English   中英

Solr拼寫檢查多詞短語

[英]Solr Spellcheck for Multi Word Phrases

我對多詞短語的solr拼寫檢查建議有問題。 用“紅辣椒”查詢

q=red+chillies&wt=xml&indent=true&spellcheck=true&spellcheck.extendedResults=true&spellcheck.collate=true

我懂了

<lst name="suggestions">
  <lst name="chillies">
    <int name="numFound">2</int>
    <int name="startOffset">4</int>
    <int name="endOffset">12</int>
    <int name="origFreq">0</int>
    <arr name="suggestion">
      <lst><str name="word">chiller</str><int name="freq">4</int></lst>
      <lst><str name="word">challis</str><int name="freq">2</int></lst>
    </arr>
  </lst>
  <bool name="correctlySpelled">false</bool>
  <str name="collation">red chiller</str>
</lst>

問題是,即使“ chiller”在索引中有4個結果,“ red chiller”也沒有。 因此,我們最終建議一個結果為0的短語。

如何使拼寫檢查僅對整個短語起作用? 我嘗試在查詢中使用KeywordTokenizerFactory:

<fieldType name="text_spell" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory" />
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> 
    <filter class="solr.LowerCaseFilterFactory" />
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory" />
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.LowerCaseFilterFactory" />
  </analyzer>
</fieldType>

我也嘗試添加

<str name="sp.query.extendedResults">false</str>

<lst name="spellchecker">

在solrconfig.xml中。

但是,兩者似乎都沒有什么不同。

使拼寫檢查僅給出對整個短語都有結果的排序規則的最佳方法是什么? 謝謝!

真正的問題是,您需要指定spellcheck.collateParam.q.op=AND ,並且(可選)指定spellcheck.collateParam.mm=100%這些參數強制正確執行了整理查詢。

您可以在solr文檔中閱讀有關此內容的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM