Solr 6.1学习笔记 -- spellcheck 组件

Posted 一剑侵心

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Solr 6.1学习笔记 -- spellcheck 组件相关的知识,希望对你有一定的参考价值。

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">

    <str name="queryAnalyzerFieldType">text_general</str>

    <!-- 下面的spellchecker使用了DirectSolrSpellChecker, 此类会使用主索引中的term进行拼写检查 -->
    <lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">text</str>
      <str name="classname">solr.DirectSolrSpellChecker</str>
      <!-- spellcheck 使用的编辑距离(由一个词转化成另一个词所做的变动), 默认值是 internal,用的是levenshtein metric-->
      <str name="distanceMeasure">internal</str>
<!-- 被认为是有效的 spellcheck suggestion的最小精度值,介于0和1之间的值。值越大,匹配的结果数越少。个人理解:假设对 cit进行拼写检查,
如果此值设置够小的话,"fat","sit"都会被认为是"cit"的正确的拼写。如果此值设置够大,则"sit"会被认为是正确的拼写
--> <float name="accuracy">0.5</float>
<!-- 值为 1 或者 2。指示最多有几个字母变动。比如:对"manag"进行拼写检查,则会找到"manager"做为正确的拼写;如果对"mana"进行
拼写检查,因为"mana"到"manager",需有3个字母的变动,所以"manager"会被遗弃
--> <int name="maxEdits">2</int>
<!-- 最小的前辍数。如设置为1,意思是指第一个字母不能错。比如:输入"cinner",虽然和"dinner"只有一个字母的编辑距离,
但是变动的是第一个字母,所以"dinner"不是"cinner"的正确拼写
--> <int name="minPrefix">1</int> <!-- maximum number of inspections per result. --> <int name="maxInspections">5</int> <!-- 进行拼写检查所需要的最小的字母数。此处设置为4,表示如果只输入了3个字母,则不会进行拼写检查(3个字母的单词都会写错的话,我也无语了) --> <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> <!-- 被推荐的词在文档中出现的最小频率。整数表示在文档中出现的次数,百分比数表示有百分之多少的文档出现了该推荐词 <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">text</str> <str name="combineWords">true</str> <str name="breakWords">true</str> <int name="maxChanges">10</int> </lst>

<!-- a spellchecker that use an alternate comparator comparatorClass be one of: 1. score (default) 2. freq (Frequency first, then score) 3. A fully qualified class name --> <!-- <lst name="spellchecker"> <str name="name">freq</str> <str name="field">lowerfilt</str> <str name="classname">solr.DirectSolrSpellChecker</str> <str name="comparatorClass">freq</str> --> </searchComponent> <!-- A request handler for demonstrating the spellcheck component. NOTE: This is purely as an example. The whole purpose of the SpellCheckComponent is to hook it into the request handler that handles your normal user queries so that a separate request is not needed to get suggestions. IN OTHER WORDS, THERE IS REALLY GOOD CHANCE THE SETUP BELOW IS NOT WHAT YOU WANT FOR YOUR PRODUCTION SYSTEM! See http://wiki.apache.org/solr/SpellCheckComponent for details on the request parameters. --> <requestHandler name="/spell" class="solr.SearchHandler" startup="lazy"> <lst name="defaults"> <!-- 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">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> </requestHandler>

 

以上是关于Solr 6.1学习笔记 -- spellcheck 组件的主要内容,如果未能解决你的问题,请参考以下文章

Solr-5.3.0学习笔记Solr Admin UI

solr 6.1 服务端 tomcat 搭建及调用

Solr学习笔记——查询

Solr学习笔记 - 目录结构

Solr学习笔记之添加文档

solr学习笔记section1-在tomcat中部署单(节点)机solr5.5.4