Solr所有检查员都需要使用相同的分析器

时间:2013-09-12 22:14:22

标签: java solr

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

我输入

时出错
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}}

任何帮助都将不胜感激。

3 个答案:

答案 0 :(得分:8)

错误表示所有定义的拼写检查器都应使用相同的字段 在您的配置中,您使用不同的字段(spellsuggest)来表示不同的格式。

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

答案 1 :(得分: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>

答案 2 :(得分:-2)

我发现我得到这个错误的原因是我称之为法术。当我更改该咒语以命名它有效。我猜法术正在被使用,这是有道理的。