Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10395

NPE during spell check with result collation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 6.2.1
    • Fix Version/s: None
    • Component/s: spellchecker
    • Labels:
      None

      Description

      I'm getting a NullPointerException when using collation during spell check. This is the message I'm getting: Exception trying to re-query to check if a spell check possibility would return any hits.

      Stack trace:

      2017-03-13 13:05:54.618 WARN (qtp472654579-84) [c:locatieserver s:dkk r:core_node4 x:locatieserver_dkk_replica2] o.a.s.s.SpellCheckCollator Exception trying to re-query to check if a spell check possibility would return any hits.
      java.lang.NullPointerException
      at org.apache.solr.spelling.SpellCheckCollator.collate(SpellCheckCollator.java:150)
      at org.apache.solr.handler.component.SpellCheckComponent.addCollationsToResponse(SpellCheckComponent.java:297)
      at org.apache.solr.handler.component.SpellCheckComponent.process(SpellCheckComponent.java:209)
      at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:295)
      at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:154)
      at org.apache.solr.core.SolrCore.execute(SolrCore.java:2089)
      ...
      

      My spell check config for this search handler:

                  <str name="spellcheck">on</str>
                  <str name="spellcheck.dictionary">suggest</str>
                  <str name="spellcheck.extendedResults">false</str>
                  <str name="spellcheck.count">5</str>
                  <str name="spellcheck.alternativeTermCount">2</str>
                  <str name="spellcheck.maxResultsForSuggest">3</str>
                  <str name="spellcheck.collate">true</str>
                  <str name="spellcheck.collateExtendedResults">true</str>
                  <str name="spellcheck.maxCollationTries">5</str>
                  <str name="spellcheck.maxCollations">3</str>
      

      The field "suggest" is a field in the index, which is also (usually) queried with this search handler. The field is filled with lots of data created by edge ngrams, since it's intended usage is for an autocomplete field.

      This issue is very similar to SOLR-8807, but the NPE is occurring one line in the code later (solr\core\src\java\org\apache\solr\spelling\SpellCheckCollator.java). As a result the patch attached to that issue probably won't work in my case.

              try {
                queryComponent.prepare(checkResponse);
                if (docCollectionLimit > 0) {
                  int f = checkResponse.getFieldFlags();
                  checkResponse.setFieldFlags(f |= SolrIndexSearcher.TERMINATE_EARLY);            
                }
                queryComponent.process(checkResponse);
                hits = (Integer) checkResponse.rsp.getToLog().get("hits");
              } catch (EarlyTerminatingCollectorException etce) {
      

      Although I'm using Solr 6.2.1, the source file is still identical to Solr 6.5.0.

      The line causing my exception is when determining the hits. I've noticed the exception only occurs when no more than 2 alternatives are found, but when 3 alternatives (maxCollations) are found, the NPE isn't occurring.

      As a workaround I could live for now with turning collations off. (Update: I've suppressed logging of these exceptions in log4j.properties.)

      Please let me know if you need more information. Thanks!

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fsteggink Frank Steggink
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: