Skip to content

The use of stored_field on root level and inner_hits level throws NPE #32941

@astefan

Description

@astefan

For the following mapping:

{                                          
  "books4" : {                             
    "aliases" : { },                       
    "mappings" : {                         
      "paper" : {                          
        "properties" : {                   
          "author" : {                     
            "type" : "nested",             
            "properties" : {               
              "name2" : {                  
                "type" : "keyword"         
              }                            
            }                              
          },                               
          "name1" : {                      
            "type" : "keyword"             
          }                                
        }                                  
      }                                    
    }
  }
}

And using this query (stored_fields: _none should be placed on both root level and inner_hits level):

{                                 
  "query": {                      
    "nested": {                   
      "path": "author",           
      "query": {                  
        "match_all": {}           
      },                          
      "inner_hits": {             
        "stored_fields": "_none_" 
      }                           
    }                             
  },                              
  "stored_fields" : "_none_"      
}

The search fails with NPE. Stacktrace below:

RemoteTransportException[[node-0][127.0.0.1:9300][indices:data/read/search[phase/query]]]; nested: NullPointerException; }
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:293)
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:133)
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:254)
        at org.elasticsearch.action.search.InitialSearchPhase.onShardFailure(InitialSearchPhase.java:106)
        at org.elasticsearch.action.search.InitialSearchPhase.access$200(InitialSearchPhase.java:50)
        at org.elasticsearch.action.search.InitialSearchPhase$2.onFailure(InitialSearchPhase.java:277)
        at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73)
        at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:51)
        at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:497)
        at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1069)
        at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1166)
        at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1150)
        at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:66)
        at org.elasticsearch.action.search.SearchTransportService$3.onFailure(SearchTransportService.java:374)
        at org.elasticsearch.search.SearchService$2.onFailure(SearchService.java:340)
        at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:334)
        at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:328)
        at org.elasticsearch.search.SearchService$3.doRun(SearchService.java:1012)
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:723)
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41)
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: ; nested: NullPointerException;
        at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:657)
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:131)
        ... 23 more
Caused by: java.lang.NullPointerException
        at org.elasticsearch.index.mapper.MapperService.documentMapper(MapperService.java:581)
        at org.elasticsearch.search.fetch.FetchPhase.createNestedSearchHit(FetchPhase.java:278)
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:147)
        at org.elasticsearch.search.fetch.subphase.InnerHitsFetchSubPhase.hitsExecute(InnerHitsFetchSubPhase.java:69)
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:165)
        at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:392)
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:367)
        at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:332)
        ... 9 more

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions