vind icon indicating copy to clipboard operation
vind copied to clipboard

NPE in SuggestionResultFactory on multi word suggestions

Open westei opened this issue 5 years ago • 0 comments

observed on: 2.1.3

A pretty default configuration:

FieldType:

    <fieldType name="text_suggest" class="solr.TextField" positionIncrementGap="100">
      <analyzer>
        <tokenizer class="solr.ClassicTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

Field: <field name="suggestions" type="text_suggest" indexed="true" stored="false" multiValued="true"/>

The field is filled with some copyField statements including titles, keywords, location names.

Note that some of the copied field use a special key

RequestHandler and InitParams

<requestHandler name="/suggester" class="com.rbmhtechnology.vind.solr.suggestion.SuggestionRequestHandler">
        <lst name="appends">
           <!-- two fq so that only published Items are included -->
            <str name="fq">published:true</str>
            <str name="fq">{!field f=published_range op=Contains}NOW</str>
        </lst>
    </requestHandler>
    <initParams path="/suggester">
      <lst name="defaults">
          <str name="echoParams">explicit</str>
          <str name="suggestion">true</str>
          <!-- the suggestion.fields with copyField configs in the schema.xml -->
          <str name="suggestion.field">[..]</str>
          <str name="suggestion.df">suggestions</str>
          <str name="suggestion.term.limit">10</str>
          <str name="spellcheck.accuracy">0.75</str>
      </lst>
      <arr name="first-components">
          <str>spellcheck</str>
      </arr>
    </initParams> 

Suggestions for a single word work fine, but as soon as the query includes multiple words like suggester?q=Excel%20Po the SuggestionResultFactory throws NPE.

java.lang.NullPointerException\n\tat com.rbmhtechnology.vind.solr.suggestion.result.SuggestionResultFactory.createSingleValueResult(SuggestionResultFactory.java:119)
	at com.rbmhtechnology.vind.solr.suggestion.service.SuggestionService.createResults(SuggestionService.java:154)
	at com.rbmhtechnology.vind.solr.suggestion.service.SuggestionService.getSuggestionResults(SuggestionService.java:121)
	at com.rbmhtechnology.vind.solr.suggestion.service.SuggestionService.run(SuggestionService.java:89)
	at com.rbmhtechnology.vind.solr.suggestion.SuggestionRequestHandler.handleRequestBody(SuggestionRequestHandler.java:246)
	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199)
	at org.apache.solr.core.SolrCore.execute(SolrCore.java:2551)

westei avatar Jan 22 '20 12:01 westei