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

Elevation with distributed search causes NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Patch Available
    • Major
    • Resolution: Unresolved
    • 8.2
    • None
    • None

    Description

      When performing a distributed search with multiple shards having elevation configured where one ore more shards do have elevated results but others do not a NullPointerException is thrown.

      We are using Solr 8.2 and have the QueryElevationComponent configured with "last-components" of the default search handler "/select". But the problem also occurs when using the explicit "/elevate" search handler.

        <requestHandler name="/select" class="solr.SearchHandler">
      	...
      	<arr name="last-components">
      	  <str>elevator</str>
      	</arr> 
        </requestHandler>
        ...
        <searchComponent name="elevator" class="solr.QueryElevationComponent" >
      	<!-- pick a fieldType to analyze queries -->
      	<str name="queryFieldType">string</str>
      	<str name="config-file">elevate.xml</str>
        </searchComponent>
      

      Steps to reproduce:

      (1) Add entries to the elevate.xml of each core to elevate a specific document for the text "elevatedTerm

      core1:
        <elevate>
          ...
          <query text="elevatedTerm"><doc id="core1docId1" /></query>
        </elevate>
      core2:
        <elevate>
          ...
          <query text="elevatedTerm"><doc id="core2docId1" /></query>
        </elevate>
      

      (2) Execute query (we use port 9983)

      http://localhost:9983/solr/core1/select?q=elevatedTerm&lowercaseOperators=false&df=text_en&defType=edismax&fq=lang:en&shards=localhost:9983/solr/core1,localhost:9983/solr/core2&fl=[elevated],[shard],area,id&rows=10&start=0
      

      As both shards have elevated documents for the requested "elevatedTerm" the search results are as expected:

      response: {
        numFound: 5192,
        start: 0,
        maxScore: 1.9032197,
        docs: [{
          area: "press",
          id: "core1docId1",
          [elevated]: true,
          [shard]: "localhost:9983/solr/core1"
        }, {
          area: "products",
          id: "core2docId1",
          [elevated]: true,
          [shard]: "localhost:9983/solr/core2"
        }, {
          area: "press",
          id: "core1docId2",
          [elevated]: false,
          [shard]: "localhost:9983/solr/core1"
        },
        ...
      

      (3) Remove the elevation entry for that "elevatedTerm" from one of the cores, e.g. via comment

      core2:
        <elevate>
          ...
          <!--
          <query text="elevatedTerm"><doc id="core2docId1" /></query>
          -->
        </elevate>
      

      (4) Reload the modified core: http://localhost:9983/solr/admin/cores?action=RELOAD&core=core2

      (5) Request same query again and you get the NPE:

      error: {
        trace: "java.lang.NullPointerException
               at org.apache.solr.handler.component.QueryComponent.unmarshalSortValues(QueryComponent.java:1068)
               at org.apache.solr.handler.component.QueryComponent.mergeIds(QueryComponent.java:917)
               at org.apache.solr.handler.component.QueryComponent.handleRegularResponses(QueryComponent.java:613)
               at org.apache.solr.handler.component.QueryComponent.handleResponses(QueryComponent.java:592)
               at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:431)
               at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199)
               at org.apache.solr.core.SolrCore.execute(SolrCore.java:2578)
               at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:780)
               at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:566)
               at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:423)
               at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:350)
               at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602)
               at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
               ...
      

      When adding the sort parameter with forceElevation=true to the query then a ClassCastException is thrown

      http://localhost:9983/solr/core1/select?q=elevatedTerm&lowercaseOperators=false&df=text_en&defType=edismax&fq=lang:en&shards=localhost:9983/solr/core1,localhost:9983/solr/core2&fl=[elevated],[shard],area,id&rows=10&start=0&sort=area%20asc&forceElevation=true
      java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at org.apache.solr.schema.FieldType.unmarshalStringSortValue(FieldType.java:1229)
        at org.apache.solr.schema.StrField.unmarshalSortValue(StrField.java:122)
        at org.apache.solr.handler.component.QueryComponent.unmarshalSortValues(QueryComponent.java:1092)
        at org.apache.solr.handler.component.QueryComponent.mergeIds(QueryComponent.java:917)
        at org.apache.solr.handler.component.QueryComponent.handleRegularResponses(QueryComponent.java:613)
        at org.apache.solr.handler.component.QueryComponent.handleResponses(QueryComponent.java:592)
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:431)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:2578)
        at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:780)
        ...
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            marc.linden Marc Linden
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: