При обращении к doc
в скрипте map_script агрегации, я получаю исключение нулевого указателя.
Для
{
"init_script":{
"source":"params._agg['transactions'] = [];"
},
"map_script":{
"source":"Debug.explain(params)" <----------------
},
...
}
Я получаю
{
...,
"painless_class":"java.util.HashMap",
"to_string":"{doc=org.elasticsearch.search.lookup.LeafDocLookup@133b9d24, _source=org.elasticsearch.search.lookup.SourceLookup@7b812d13, _doc=org.elasticsearch.search.lookup.LeafDocLookup@133b9d24, _fields=org.elasticsearch.search.lookup.LeafFieldsLookup@6149f5f3, _agg={transactions=[]}}",
"java_class":"java.util.HashMap",
...
}
Здесь Debug.explain(params._agg)
доступен без проблем, как и Debug.explain(params.containsKey('doc'))
, который возвращает
{
...,
"painless_class":"java.lang.Boolean",
"to_string":"true",
"java_class":"java.lang.Boolean",
...
}
Если, однако, я получаю доступ к
params.doc
params['_doc']
doc
_doc
- или любой их вариант
Я продолжаю получать
{
...,
"caused_by":{
"type":"null_pointer_exception",
"reason":null,
"caused_by":{
"type":"null_pointer_exception",
"reason":null
}
},
...
}
Что происходит? И почему я вижу LeafDocLookup
экземпляров, к которым нельзя получить доступ и которые выглядят не строковыми / toString () - ed?
трассировка стека Кибана:
{
"error":{
"root_cause":[
{
"type":"null_pointer_exception",
"reason":null
}
],
"type":"search_phase_execution_exception",
"reason":"all shards failed",
"phase":"query",
"grouped":true,
"failed_shards":[
{
"shard":0,
"index":"abcdefgh",
"node":"C2dBtzqBQOOiH5G5IGQPkQ",
"reason":{
"type":"null_pointer_exception",
"reason":null
}
}
],
"caused_by":{
"type":"null_pointer_exception",
"reason":null,
"caused_by":{
"type":"null_pointer_exception",
"reason":null
}
}
},
"status":500
}
ES Stack Trace
org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:288) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:128) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:249) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.InitialSearchPhase.onShardFailure(InitialSearchPhase.java:101) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.InitialSearchPhase.access$100(InitialSearchPhase.java:48) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.InitialSearchPhase$2.lambda$onFailure$1(InitialSearchPhase.java:222) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.InitialSearchPhase.maybeFork(InitialSearchPhase.java:176) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.InitialSearchPhase.access$000(InitialSearchPhase.java:48) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.InitialSearchPhase$2.onFailure(InitialSearchPhase.java:222) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:51) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:527) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1103) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1196) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1180) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:66) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.SearchTransportService$6$1.onFailure(SearchTransportService.java:385) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService$2.onFailure(SearchService.java:341) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:335) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:329) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService$3.doRun(SearchService.java:1019) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:725) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.3.1.jar:6.3.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: org.elasticsearch.ElasticsearchException$1
at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:658) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:126) ~[elasticsearch-6.3.1.jar:6.3.1]
... 26 more
Caused by: java.lang.NullPointerException
at org.elasticsearch.painless.Definition.getTypeInternal(Definition.java:1364) ~[?:?]
at org.elasticsearch.painless.Definition.getType(Definition.java:447) ~[?:?]
at org.elasticsearch.painless.Definition.ClassToType(Definition.java:615) ~[?:?]
at org.elasticsearch.painless.PainlessExplainError.getHeaders(PainlessExplainError.java:57) ~[?:?]
at org.elasticsearch.painless.PainlessScript$Script.execute(Debug.explain(params['doc']):21) ~[?:?]
at org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:105) ~[?:?]
at org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetricAggregator$1.collect(ScriptedMetricAggregator.java:71) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.aggregations.LeafBucketCollector$2.collect(LeafBucketCollector.java:67) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.aggregations.LeafBucketCollector.collect(LeafBucketCollector.java:82) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.apache.lucene.search.MultiCollector$MultiLeafCollector.collect(MultiCollector.java:174) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.apache.lucene.search.FilterLeafCollector.collect(FilterLeafCollector.java:43) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:233) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:184) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.apache.lucene.search.ConstantScoreQuery$ConstantBulkScorer.score(ConstantScoreQuery.java:84) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:660) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:191) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:462) ~[lucene-core-7.3.1.jar:7.3.1 ae0705edb59eaa567fe13ed3a222fdadc7153680 - caomanhdat - 2018-05-09 09:27:24]
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:266) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:107) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:324) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:357) ~[elasticsearch-6.3.1.jar:6.3.1]
at org.elasticsearch.search.SearchService$2.onResponse(SearchService.java:333) ~[elasticsearch-6.3.1.jar:6.3.1]