Solr spellcheck: cannot show result, always receiv

2019-03-02 07:20发布

问题:

So, Im quite new on solr, and maybe I have so many understanding problems.

What Im trying to do right now, its an autosuggestion for my search bar. For example, if you write "glves", the result should be "gloves". This is inside an autocomplete, which works fine right now. But of course, when I type "glves", nothing appear.

Right now, when you write "gloves", all the items with have the word "gloves" on the item field, appear. I want this too for the term "glves".

This is my 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" />

The fields above, are working good to my purpose. The field I need to index for the searches is item.

And this is what I have on my 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>

But each time I make a query to solr, ie:

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

I get the same response:

<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>

I try to follow lots of manuals, tips, old questions on these forums, but Im not getting nothing helpful for me.

Thanks for your time.

回答1:

I found this answer to help me solving a similar problem with the exact same error message. Your problem might be that you have defined two different fields for the different spell check definitions:

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

these should be equal. This is what Solr is complaining about.



标签: solr