【问题标题】:Solr - How to obtain multiple suggestions for a querySolr - 如何获取查询的多个建议
【发布时间】:2013-09-18 13:54:45
【问题描述】:

在配置文件solrconfig.xml中,是否有一个参数可以调整容差,即使querysuggestion之间的不同字母数量很大,也可以有多个建议?

在我的solrconfig.xml 建议配置中,我有:

spellchecksearch component

<lst name="spellchecker">
    <str name="name">default</str>
    <str name="field">title</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">4</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>

<!-- a spellchecker that can break or combine words.  See "/spell" handler below for usage -->
<lst name="spellchecker">
    <str name="name">wordbreak</str>
    <str name="classname">solr.WordBreakSolrSpellChecker</str>
    <str name="field">title</str>
    <str name="combineWords">true</str>
    <str name="breakWords">true</str>
    <int name="maxChanges">10</int>
</lst>

还有/spellrequest handler

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
        <str name="df">title</str>
        <!-- Solr will use suggestions from both the 'default' spellchecker
        and from the 'wordbreak' spellchecker and combine them.
        collations (re-written queries) can include a combination of
        corrections from both spellcheckers -->
        <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">1000</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>
        <str name="spellcheck.onlyMorePopular">false</str>
    </lst>
    <arr name="last-components">
        <str>spellcheck</str>
    </arr>
</requestHandler>

我的问题是我总是只能通过查询获得一个建议。例如,对于查询renou,我想得到renault 作为建议,即使还有其他更接近的词。

【问题讨论】:

    标签: solr solr4 search-suggestion


    【解决方案1】:

    对于您的情况,最好使用Suggester 而不是Spellchecker,因为Spellchecker 仅生成1 和2 个字母更改的候选。 Suggester 返回以您的查询开头的单词。要建议更改拼写的单词,您应该使用FuzzySuggester

    【讨论】:

    • 我想我会坚持使用spellcheck 组件,因为它更适合语法检查。而且,我认为这个suggester 用于autocompletionsyntax checking 使用shingles filter 更多。
    • 是的,但是您的示例是单词的开头。如果您希望拼写检查器为单词不同部分的 4 个字母距离生成假设,则不能使用拼写检查器,因为它只生成 1 个和 2 个字母距离的候选。您可以尝试将solr.DoubleMetaphoneFilterFactor 用于您应用DirectSpellChecker 以获得超过2 个字母的距离。
    猜你喜欢
    • 1970-01-01
    • 2013-12-27
    • 2012-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 2023-02-08
    相关资源
    最近更新 更多