本文介绍了请求句柄 solrconfig.xml Spellchecker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 solr 文档,我正在尝试设置拼写检查器.但是当我测试时,我没有任何建议.我的一段代码如下:

I am trying to set up spellchecker, according to solr documentation. But when I am testing, I don't have any suggestion. My piece of code follows:

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

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

    <lst name="spellchecker">
      <str name="classname">solr.IndexBasedSpellChecker</str>
      <str name="name">default</str>
      <str name="field">name</str>
      <str name="spellcheckIndexDir">./spellchecker</str>
    </lst>
    <str name="queryAnalyzerFieldType">textSpell</str>

  </searchComponent>


 <requestHandler name="/spellcheck" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <!-- Optional, must match spell checker's name as defined above, defaults to "default" -->
      <str name="spellcheck.dictionary">default</str>
      <!-- omp = Only More Popular -->
      <str name="spellcheck.onlyMorePopular">false</str>
      <!-- exr = Extended Results -->
      <str name="spellcheck.extendedResults">false</str>
      <!--  The number of suggestions to return -->
      <str name="spellcheck.count">1</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
  </requestHandler>

我发送给 Solr 的查询:
q=%2B%28text%3A%28gasal%29%29&suggestField=contentOriginal&ontologySeed=gasal&spellcheck.build=true&spellcheck.q=gasal&spellcheck=true&spellcheck.collat​​e=true&hl=true&hl.snippets=5&hl.fl=text&hl.fl=text&rows=12&start=0&qt=%2Fsuggestprobabilistic

The query I send to Solr:
q=%2B%28text%3A%28gasal%29%29&suggestField=contentOriginal&ontologySeed=gasal&spellcheck.build=true&spellcheck.q=gasal&spellcheck=true&spellcheck.collate=true&hl=true&hl.snippets=5&hl.fl=text&hl.fl=text&rows=12&start=0&qt=%2Fsuggestprobabilistic

有人知道为什么吗??提前致谢

Does anybody know why?? Thanks in advance

推荐答案

首先,不要在组件配置中重复 queryAnalyzerFieldType 两次.

First, don't repeat queryAnalyzerFieldType twice in the component configuration.

建议不要使用 /spellcheck 处理程序,而是将拼写检查组件绑定到标准查询处理程序(如果您使用的是 dismax),如下所示:

It is recommended not to use a /spellcheck handler but instead to bind the spellcheck component to the standard query handler (or dismax if it is what you use) like this:

<requestHandler name="standard" class="solr.SearchHandler" default="true">
 <lst name="defaults">
    ...
 </lst>
 <arr name="last-components">
    <str>spellcheck</str>
    ...
 </arr>
</requestHandler>

然后你可以这样称呼它:
http://localhost:8983/solr/select?q=komputer&spellcheck=true

You can then call it like this:
http://localhost:8983/solr/select?q=komputer&spellcheck=true

在使用之前不要忘记构建拼写检查字典:
http://localhost:8983/solr/select/?q=*:*&spellcheck=true&spellcheck.build=true

您可以通过在组件中配置字典来强制在每次提交时构建字典:

You can force the dictionary to build at each commit by configuring it in the component:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
 <str name="queryAnalyzerFieldType">textSpell</str>
 <lst name="spellchecker">
  <str name="classname">solr.IndexBasedSpellChecker</str>
  <str name="name">default</str>
  <str name="field">name</str>
  <str name="spellcheckIndexDir">./spellchecker1</str>
  <str name="buildOnCommit">true</str>
 </lst>
</searchComponent>

最后,确保您的 name 字段确实是 textSpell 类型的索引字段,并且它包含足够的内容来构建一个好的字典.在我的例子中,我有一个名为 spellchecker 的字段,它由我的索引的几个字段填充(使用架构中的 copyField 指令).

Finally, make sure that your name field is really an indexed field of type textSpell and that it contains enough content to build a good dictionary. In my case, I have a field named spellchecker that is populated from a couple of fields of my index (using copyField instructions in the schema).

这篇关于请求句柄 solrconfig.xml Spellchecker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-10 03:47