7

我正在尝试对一些索引数据运行拼写检查。我最初想出了如何做到这一点,但我搞砸了一些配置,现在它说“所有检查器都需要使用相同的分析器”。我读过这是因为“字段”值被命名为不同的东西。我已将所有拼写检查组件拼写。我还有什么做错的。

我输入时收到该错误是

http://localhost:8080/solr/collection1/select?q=name%3Adoc&wt=json&indent=true&spellcheck=true&spellcheck.collate=true&spellcheck.build=true

我的 solrconfig.xml


<requestHandler name="/select" class="solr.SearchHandler">

    <lst name="defaults">
        <!-- Optional, must match spell checker's name as defined above, defaults to "default" -->
        <str name="spellcheck.dictionary">default</str>
        <!-- Also generate Word Break Suggestions (Solr 4.0 see SOLR-2993) -->
        <str name="spellcheck.dictionary">wordbreak</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">10</str>
    </lst>
    <arr name="last-components">
        <str>spellcheck</str>
    </arr>

</requestHandler>

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

        <str name="name">default</str>
        <!-- The classname is optional, defaults to IndexBasedSpellChecker -->
        <str name="classname">solr.IndexBasedSpellChecker</str>

        <str name="field">spell</str>
        <!-- Optional, by default use in-memory index (RAMDirectory) -->
        <str name="spellcheckIndexDir">./spellchecker</str>
        <!-- Set the accuracy (float) to be used for the suggestions. Default is 0.5 -->
        <str name="accuracy">0.7</str>
        <!-- Require terms to occur in 1/100th of 1% of documents in order to be included in the   dictionary -->
        <float name="thresholdTokenFrequency">.0001</float>
    </lst>
    <!-- a spellchecker that can break or combine words. (Solr 4.0 see SOLR-2993) -->
    <lst name="spellchecker">
        <str name="name">wordbreak</str>
        <str name="classname">solr.WordBreakSolrSpellChecker</str>
        <str name="field">spell</str>
        <str name="combineWords">true</str>
        <str name="breakWords">true</str>
        <int name="maxChanges">3</int>
    </lst>
    <!-- Example of using different distance measure -->
    <lst name="spellchecker">
        <str name="name">jarowinkler</str>
        <str name="field">spell</str>
        <!--  Use a different Distance Measure -->
        <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
        <str name="spellcheckIndexDir">./spellchecker</str>
    </lst>

    <!-- This field type's analyzer is used by the QueryConverter to tokenize the value for "q" parameter -->
    <str name="queryAnalyzerFieldType">textSpell</str>
</searchComponent>


<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">spell</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>

        <str name="field">suggest</str>
        <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="spellcheck">true</str>
        <str name="spellcheck.dictionary">suggest</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.count">5</str>
        <str name="spellcheck.collate">true</str>
    </lst>

    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

我的 schema.xml

<field name="id" type="string" indexed="true" stored="true" required="true"  multiValued="false" />
<field name="sku" type="text_en_splitting_tight" indexed="true" stored="true" omitNorms="true"/>
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="manu" type="text_general" indexed="true" stored="true" omitNorms="true"/>
<field name="cat" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="features" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="includes" type="text_general" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />

<field name="weight" type="float" indexed="true" stored="true"/>
<field name="price"  type="float" indexed="true" stored="true"/>
<field name="popularity" type="int" indexed="true" stored="true" />
<field name="inStock" type="boolean" indexed="true" stored="true" />

<field name="store" type="location" indexed="true" stored="true"/>

堆栈跟踪

    java.lang.IllegalArgumentException: All checkers need to use the 
    same Analyzer.\n\tat org.apache.solr.spelling.ConjunctionSolrSpellChecker.addChecker(
    ConjunctionSolrSpellChecker.java:79)\n\tat org.apache.
    solr.handler.component.SpellCheckComponent.getSpellChecker(SpellCheckComponent.java:501)
    \n\tat org.apache.solr.handler.component.SpellCheckComponent.prepare(SpellCheckComponent.
    java:122)\n\tat org.apache.solr.handler.component.SearchHandler.handleRequestBody
    (SearchHandler.java:187)\n\tat org.apache.solr.handler.RequestHandlerBase.handleRequest
    (RequestHandlerBase.java:135)\n\tat org.apache.solr.core.SolrCore.execute
    (SolrCore.java:1904)\n\tat org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:659)
    \n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter
    (SolrDispatchFilter.java:362)\n\tat org.apache.solr.servlet.SolrDispatchFilter.doFilter
    (SolrDispatchFilter.java:158)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
    (ApplicationFilterChain.java:243)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter
    (ApplicationFilterChain.java:210)\n\tat org.apache.catalina.core.StandardWrapperValve.invoke
    (StandardWrapperValve.java:222)\n\tat org.apache.catalina.core.StandardContextValve.invoke
    (StandardContextValve.java:123)\n\tat org.apache.catalina.core.StandardHostValve.invoke
    (StandardHostValve.java:171)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke
    (ErrorReportValve.java:99)\n\tat org.apache.catalina.valves.AccessLogValve.invoke
    (AccessLogValve.java:953)\n\tat org.apache.catalina.core.StandardEngineValve.invoke
    (StandardEngineValve.java:118)\n\tat org.apache.catalina.connector.CoyoteAdapter.service
    (CoyoteAdapter.java:408)\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    \n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
    (AbstractProtocol.java:589)\n\tat org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    \n\tat java.util.concurrent.ThreadPoolExecutor$Worker.runTask
    (ThreadPoolExecutor.java:886)
    \n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)\n\tat java.lang.Thread.run(Thread.java:662)\n",
        "code":500}}

任何帮助,将不胜感激。

4

3 回答 3

10

错误指示所有定义的拼写检查器都应使用相同的字段。
在您的配置中,您为不同的检查器使用不同的字段 ( spell& suggest)。

<str name="field">spell</str><str name="field">suggest</str>

于 2013-09-13T04:03:29.760 回答
2

拼写检查器组件中使用的所有字段(在示例拼写和建议中)必须使用相同的分析链。分析链意味着它们必须配置为相同的字段类型。

  <field name="spell" type="spellchecker" indexed="true" stored="true"/>
  <field name="suggest" type="spellchecker" indexed="true" stored="true"/>

  <fieldType name="spellchecker" class="solr.TextField">
    <analyzer>
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
  </fieldType>
于 2015-05-20T10:43:50.960 回答
-3

我发现我收到这个错误的原因是我称之为拼写。当我改变那个咒语来命名它时,它起作用了。我猜咒语正在被使用,这是有道理的。

于 2013-09-17T18:40:13.263 回答