Solr拼写检查:无法显示结果,始终收到相同的错误

时间:2013-04-14 17:19:11

标签: solr

所以,我对solr很新,也许我有很多理解问题。

我正在尝试做什么,它是我的搜索栏的自动提示。 例如,如果你写“glves”,结果应该是“手套”。这是一个自动完成,现在工作正常。但当然,当我输入“glves”时,什么都没有出现。

现在,当您编写“手套”时,会出现项目字段上带有“手套”字样的所有项目。对于“glves”一词,我也想要这个。

这是我的schema.xml:

    <field name="_version_" type="long" indexed="true" stored="true"/>
    <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>
    <field name="oxid" type="string" indexed="true" stored="true" required="true" multiValued="false" />
    <field name="ean" type="string" indexed="true" required="false" />
    <field name="marken" type="text_en" indexed="true" stored="true" />
    <field name="item" type="text_en" indexed="true" stored="true" />
    <field name="shortdesc" type="text_de" indexed="true" stored="true" />
    <field name="price" type="float" indexed="true" stored="true" />
    <field name="picture" type="string" indexed="true" stored="true" />
    <field name="seourl" type="string" indexed="true" stored="true" />
    <field name="item_autocomplete" type="text_autocomplete" indexed="true" stored="false" />
    <field name="item_show" type="string" indexed="true" stored="false" />

上面的字段对我的目的很有帮助。我需要为搜索索引的字段是item。

这就是我在solrconfig.xml上的内容:

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

<str name="queryAnalyzerFieldType">item</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">item</str>
  <str name="classname">solr.DirectSolrSpellChecker</str>
    <str name="spellcheckIndexDir">./spellchecker</str>
  <str name="buildOnOptimize">true</str>
  <str name="buildOnCommit">true</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>

<!-- 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">name</str>
  <str name="combineWords">true</str>
  <str name="breakWords">true</str>
  <int name="maxChanges">10</int>
</lst>

但每次我对solr进行查询,即:

http://localhost:8983/solr/spell?spellcheck=true&qt=spellchecker&spellcheck.accuracy=0.8&spellcheck.collate=true&extendedResults=true+&q=glovs

我得到同样的答复:

<response><lst name="responseHeader"><int name="status">500</int><int name="QTime">2</int></lst><lst name="error"><str name="msg">All checkers need to use the same Analyzer.</str><str name="trace">java.lang.IllegalArgumentException: All checkers need to use the same Analyzer.
at org.apache.solr.spelling.ConjunctionSolrSpellChecker.addChecker(ConjunctionSolrSpellChecker.java:79)
at org.apache.solr.handler.component.SpellCheckComponent.getSpellChecker(SpellCheckComponent.java:475)
at org.apache.solr.handler.component.SpellCheckComponent.prepare(SpellCheckComponent.java:106)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:187)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.core.RequestHandlers$LazyRequestHandlerWrapper.handleRequest(RequestHandlers.java:242)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1797)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:637)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:343)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:141)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
</str><int name="code">500</int></lst></response>

我尝试在这些论坛上关注大量的手册,提示和旧问题,但我没有对我有任何帮助。

感谢您的时间。

1 个答案:

答案 0 :(得分:3)

我找到了this answer来帮助我解决类似的问题,并使用完全相同的错误消息。 您的问题可能是您为不同的拼写检查定义定义了两个不同的字段:

<str name="field">item</str><str name="field">name</str>

这些应该是平等的。这就是Solr所抱怨的。