Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
astefan opened this issue Aug 17, 2018 · 4 comments
Closed

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

astefan opened this issue Aug 17, 2018 · 4 comments

Comments

@astefan
Copy link
Contributor

astefan commented Aug 17, 2018

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
@astefan astefan added the :Analytics/Aggregations Aggregations label Aug 17, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@jimczi jimczi added the >bug label Aug 17, 2018
@jimczi jimczi self-assigned this Aug 17, 2018
jimczi added a commit to jimczi/elasticsearch that referenced this issue Aug 21, 2018
Now that types are unique per mapping we can retrieve the document mapper
without referencing the type. This fixes an NPE when stored fields are disabled.
For 6x we'll need a different fix since mappings can still have multiple types.

Relates elastic#32941
jimczi added a commit that referenced this issue Sep 4, 2018
…3018)

Now that types are unique per mapping we can retrieve the document mapper
without referencing the type. This fixes an NPE when stored fields are disabled.
For 6x we'll need a different fix since mappings can still have multiple types.

Relates #32941
@astefan
Copy link
Contributor Author

astefan commented Oct 19, 2018

@jimczi can this fix be backported to 6.5 as well?

@jimczi
Copy link
Contributor

jimczi commented Oct 19, 2018

It needs to be modified to handle multi-types but it's certainly doable @astefan. I'll work on a pr.

jimczi added a commit that referenced this issue Oct 24, 2018
This is the backport of #33018, a change was needed to handle indices with multiple types.
This change throws an error if stored fields are disabled on `inner_hits` for an index with multiple types

Closes #32941
@astefan
Copy link
Contributor Author

astefan commented Oct 29, 2018

Tested the relevant SQL issues this was causing and it's all fixed. Thanks again @jimczi

@astefan astefan closed this as completed Oct 29, 2018
astefan added a commit that referenced this issue Oct 30, 2018
Added a test for a bug in Elasticsearch (#32941) that had implications in SQL and activated another test that didn't work in the past
astefan added a commit that referenced this issue Oct 30, 2018
Added a test for a bug in Elasticsearch (#32941) that had implications in SQL and activated another test that didn't work in the past
astefan added a commit that referenced this issue Oct 30, 2018
Added a test for a bug in Elasticsearch (#32941) that had implications in SQL and activated another test that didn't work in the past
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants