【问题标题】:How to get Solr suggester work on misspellings too?如何让 Solr 建议器也处理拼写错误?
【发布时间】:2014-07-15 08:50:45
【问题描述】:

我正在使用 solr 实现一个小型网络搜索引擎,并且正在使用 Suggester 组件 在查询表单中提供自动完成功能。

我可以从 solr 获得建议,但我也希望更正拼写错误。 我要问的和this question一样 但我使用了不同的处理程序配置(在将最终查询提交给 /select 之前,我将部分查询提交给单独的 /suggest 请求处理程序)。

来自 SolrConfig.xml

<searchComponent class="solr.SpellCheckComponent" name="suggest">
<lst name="spellchecker">
  <str name="name">suggest</str>
<!--  <str name="classname">solr.DirectSolrSpellChecker</str> -->
  <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
  <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookupFactory</str>
  <str name="field">spelling</str>  <!-- all the other fields are copied here -->
  <float name="threshold">0.005</float>
  <str name="buildOnCommit">true</str>
</lst>
</searchComponent>

<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
  <str name="suggest">true</str>
  <str name="suggest.count">10</str>
  <str name="spellcheck">true</str>
  <str name="spellcheck.extendedResults">true</str>
  <str name="spellcheck.dictionary">suggest</str>
  <!-- <str name="spellcheck.dictionary">default</str> -->
  <str name="spellcheck.onlyMorePopular">true</str>
  <str name="spellcheck.count">5</str>
  <str name="spellcheck.alternativeTermCount">5</str>
  <str name="spellcheck.maxResultsForSuggest">5</str>
  <str name="spellcheck.collate">true</str>
  <str name="spellcheck.maxCollations">5</str>      
</lst>
<arr name="components">
  <str>suggest</str>
 <!-- <str>spellcheck</str> enabling this gives me error: dictionary not found: suggest (same for "default")-->
</arr>
</requestHandler>`

将建议器组件的类名更改为 directSolrSpellChecker 可以进行拼写检查,但不能提供建议。

我怎样才能让建议者也对拼写更正进行操作?

【问题讨论】:

    标签: search solr autosuggest


    【解决方案1】:

    尝试使用 thsi:

    <!-- a spellchecker built from a field of the main index -->
    <lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">spelling</str>
      <str name="classname">solr.DirectSolrSpellChecker</str>
      <!-- the spellcheck distance measure used, the default is the internal levenshtein -->
      <str name="distanceMeasure">internal</str>
      <!-- minimum accuracy needed to be considered a valid spellcheck suggestion -->
      <float name="accuracy">0.5</float>
      <!-- the maximum #edits we consider when enumerating terms: can be 1 or 2 -->
      <int name="maxEdits">2</int>
      <!-- the minimum shared prefix when enumerating terms -->
      <int name="minPrefix">1</int>
      <!-- maximum number of inspections per result. -->
      <int name="maxInspections">5</int>
      <!-- minimum length of a query term to be considered for correction -->
      <int name="minQueryLength">2</int>
      <!-- maximum threshold of documents a query term can appear to be considered for correction -->
      <float name="maxQueryFrequency">0.01</float>
      <!-- uncomment this to require suggestions to occur in 1% of the documents
        <float name="thresholdTokenFrequency">.01</float>
      -->
    </lst>
    

      <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="df">spelling</str>
      <str name="spellcheck.dictionary">default</str>
      <str name="spellcheck.dictionary">wordbreak</str>
      <str name="spellcheck">on</str>
      <str name="spellcheck.extendedResults">true</str>       
      <str name="spellcheck.count">10</str>
      <str name="spellcheck.alternativeTermCount">5</str>
      <str name="spellcheck.maxResultsForSuggest">5</str>       
      <str name="spellcheck.collate">true</str>
      <str name="spellcheck.collateExtendedResults">true</str>  
      <str name="spellcheck.maxCollationTries">10</str>
      <str name="spellcheck.maxCollations">5</str>         
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多