当前位置: 首页 > 知识库问答 >
问题:

Solr:拼写检查不能与select查询一起工作

法弘壮
2023-03-14

http://localhost:8983/solr/prashant1/spell?q=blakc&spellcheck=on&wt=json

结果

{
  "responseHeader":{
    "status":0,
    "QTime":8},
  "response":{"numFound":0,"start":0,"docs":[]
  },
  "spellcheck":{
    "suggestions":[
      "blakc",{
        "numFound":10,
        "startOffset":0,
        "endOffset":5,
        "origFreq":0,
        "suggestion":[{
            "word":"black",
            "freq":65146},
          {
            "word":"blanc",
            "freq":151},
          {
            "word":"blake",
            "freq":10},
          {
            "word":"blac",
            "freq":2},
          {
            "word":"block",
            "freq":1863},
          {
            "word":"blanca",
            "freq":32},
          {
            "word":"blank",
            "freq":31},
          {
            "word":"blade",
            "freq":23},
          {
            "word":"blacks",
            "freq":12},
          {
            "word":"blanco",
            "freq":11}]}],
    "correctlySpelled":false,
    "collations":[]}}

但我需要与select查询相同的结果,它不能从SOLR管理中工作。

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <str name="queryAnalyzerFieldType">text_general</str>
    <!-- Multiple "Spell Checkers" can be declared and used by this
         component
      -->
    <!-- a spellchecker built from a field of the main index -->
    <lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">Name</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>
</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="spellcheck.dictionary">default</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>

有没有设置和步骤要做?

共有1个答案

尹承泽
2023-03-14

尝试将spellcheck组件添加到标准查询处理程序中,如

<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
      <int name="rows">10</int>

    <str name="spellcheck">on</str>
      <str name="spellcheck.extendedResults">true</str>
      <str name="spellcheck.count">10</str>
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
</requestHandler>

然后可以这样称呼它:

http://localhost:8983/solr/select?q=yogik&spellcheck=true

另外,在使用拼写检查词典之前,不要忘记构建它:

http://localhost:8983/solr/select/?q=*:*&spellcheck=true&spellcheck.build=true
 类似资料:
  • 我对Lucene的不同查询对象进行了一些试验,并试图理解为什么在使用WhitespaceAnaylzer进行索引时,前缀查询与任何文档都不匹配。考虑以下测试代码: 如果我用StandardAnalyzer替换WhitespaceAnaylzer,测试就会通过。我使用Luke检查索引内容,但在索引过程中Lucene存储值的方式上找不到任何差异。谁能澄清一下出了什么问题吗?

  • 我是GraphQL的新手。我使用express-graphql在REST API上为petSore模式生成graphql查询。我能够使用graphql查询获得get API的结果,但无法使用突变获得POST/PUT API的响应。)为了创建宠物,我使用突变, null

  • 概述 Sublime Text 使用Hunspell来进行拼写检查,可以从OpenOffice.org Extension List获取额外的字典。 Sublime Text 可用字典:https://github.com/SublimeText/Dictionaries 字典 Sublime Text 目前只支持 UTF-8 编码格式的字典,大多数字典并没有使用 UTF-8 字典,而是使用了和其

  • 自 Electron 8 以来已内置支持 Chromium 拼写检查器。 On Windows and Linux this is powered by Hunspell dictionaries, and on macOS it makes use of the native spellchecker APIs. How to enable the spellchecker? 对于 Electr

  • 我对Python和NLTK相当陌生。我正忙于一个可以执行拼写检查的应用程序(用正确的单词替换拼写错误的单词)。我目前正在使用Python 2.7上的附魔库、PyEnchant和NLTK库。下面的代码是一个处理更正/替换的类。 我编写了一个函数,它接收单词列表,对每个单词执行replace(),然后返回这些单词的列表,但拼写正确。 现在,我真的不喜欢这个,因为它不是很准确,我正在寻找一种方法来实现拼

  • 问题内容: 我想写一些类似的东西: 这有效: 这有效: 像这样的作品: 但是我需要在Meeting_time上做一个大于查询的事情,所以我需要将它写为一个字符串,我认为呢? 但是,两个sql查询在一起都会产生以下错误: 我觉得我好近……我在这里想念什么? 问题答案: 当不清楚该列来自哪个表时,会出现此消息。这应该工作: