gpt4 book ai didi

search - 如何让 Solr suggester 也处理拼写错误?

转载 作者:行者123 更新时间:2023-12-05 07:58:41 25 4
gpt4 key购买 nike

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

我可以从 solr 获得建议,但我也想更正拼写错误。我要问的与 this question 相同但是我使用了不同的处理程序配置(我将部分查询提交给单独的/suggest 请求处理程序,然后再将我的最终查询提交给/select)。

来自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>`

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

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

最佳答案

尝试使用这个:

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

关于search - 如何让 Solr suggester 也处理拼写错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23872517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com