es7.4 score_script 查询报错 search_phase_execution_exception

发布于 2022-09-12 00:19:12 字数 16928 浏览 15 评论 0

当ts查询的from和to的时间范围在库中没有记录时,查询报错,能稳定复现。_有对应的数据则能正常返回。_

在此求助各位大佬,感激不尽!!

原始完整的restful请求:

GET /vec_face/_search

{
  "from": 0,
  "size": 10,
  "timeout": "2s",
  "query": {
    "script_score": {
      "query": {
        "range": {
          "ts": {
            "from": 1577188652,
            "to": 1577188656,
            "include_lower": true,
            "include_upper": true,
            "boost": 1
          }
        }
      },
      "script": {
        "source": "1 / (1 + l2norm(params.vec, doc['vec']))",
        "lang": "painless",
        "params": {
          "vec":[1.6785023,0.4476218,-0.16651529,0.5682781,-1.4364908,1.6720887,-1.306206,0.32019794,0.56361294,0.7606286,0.70324403,0.8500672,0.47245103,0.22106682,0.27767122,-0.135088,-0.37843606,-0.24500278,0.28103572,-2.180455,-1.6444798,-0.46396294,0.25094777,1.0558114,0.2748616,0.1458264,-0.05148666,1.0794576,1.262478,0.5277722,-0.009849307,0.19464393,-0.8369613,0.9455171,0.8057336,-0.21259215,-0.36186662,-0.8383655,-0.94022465,2.3965015,0.5405268,-0.24268903,-1.237904,1.0180176,0.26705486,-0.8805857,0.29948142,1.0734811,-1.2823912,-0.271083,1.9409878,1.2034167,0.16907866,2.1436126,1.1809387,-1.3243539,-1.6644677,0.16868807,-0.23778605,0.3116475,-0.4051765,0.1286545,-1.835101,-0.37917957,0.09772799,0.7000277,-0.04776964,0.7517305,0.37506446,-0.015283321,0.7910633,-1.9823483,-1.0377803,0.00046020374,0.28948328,0.83875024,0.5593379,-1.5971214,0.3011275,-0.24126816,-0.19214596,-1.2991853,-2.4281693,-0.19600147,1.6715014,0.4185478,0.26430452,-0.038241625,-0.19122154,-0.7110511,0.31816566,-0.40278617,-0.9543032,0.49583003,-0.47190338,-0.36738408,-0.32968414,-1.4255946,0.9379127,-1.0471557,1.2494103,0.8347406,0.1221316,1.4107251,-0.32632148,0.48664418,-0.30517912,-1.3639647,-0.15511738,-1.2975485,0.40690067,-0.9988617,-2.0281687,-1.8317724,-1.3548101,-0.25284633,-0.8689032,-0.7813476,1.0928949,-0.110328004,1.0790398,-1.7071997,0.8946733,-0.56873703,0.78049785,0.40838948,0.73716974,0.63884145,0.12303414,0.12476907,-0.94503665,0.2694527,-0.40637654,-0.7616645,-0.3352997,-2.3360672,-0.20650628,0.63699913,-1.3240391,2.2357783,-0.36057046,-0.9701303,0.5700494,0.68307036,-1.0748969,1.8961545,0.542627,-1.2859539,-0.9531138,-0.11695091,1.2045685,0.84357846,-0.26093334,0.6424861,0.17572072,0.943574,-1.1804206,-1.6041664,0.6020292,1.5852503,-0.7513164,-1.1001111,1.3844328,-0.011168821,-1.1509103,0.64260435,-2.0998921,-0.24581255,0.6549659,-0.43786338,-1.3711926,1.5707769,-0.50053215,-0.14475554,-0.5324108,0.7397226,-0.781785,0.6049348,-0.18729874,-1.27953,-0.27429724,2.1166496,-0.6767965,0.4862654,0.49993494,-0.15201727,0.17845142,1.8597386,0.50426036,1.3752688,0.15487354,-1.8821903,1.0527948,-1.2101613,-1.2876459,0.388445,2.3579261,1.7037861,0.6217252,-1.8144671,-0.022515794,-0.22794054,-0.4567321,-0.5853479,-1.2864231,1.114938,0.00069510355,2.6974673,-0.22750449,-0.3507474,2.8680594,0.8087761,0.22640671,0.4508515,-0.58131415,-0.67669684,-1.8555402,0.6547786,-0.69760984,-1.2741696,0.032905642,-0.40127203,-0.73256135,0.0197819,-0.49968296,1.1016649,0.7180523,-1.1871898,0.71795297,-0.87800235,1.6375352,1.1215172,-0.630473,0.51663226,0.56718224,-0.75633866,0.2430262,0.9831455,0.23183198,1.9463514,-0.28584507,-1.3567102,-1.4049042,-0.036026873,1.4508443,-1.1083984,0.16715753,-0.36579877,-0.16440082,-0.4520262,-1.8082186,-2.1480665,0.17070611,0.7514304,-0.9755032,-2.5160143,-0.78335774,0.97648704,0.19036554,1.4152055,-0.1389002,-1.1746283,0.13798904,-0.38898227,-1.4964585,-0.08398554,0.6485292,-0.8134028,0.64079964,-0.7062007,-2.5336037,1.4326617,-0.5016053,1.2888147,-0.8449732,-0.28010213,1.0107032,0.08980253,-0.30659902,0.84223515,-0.84179,0.8186067,0.8811588,0.061863508,-0.8785575,-0.07946481,-1.0525128,0.19944407,-1.9470391,-1.6499077,-0.10589136,-0.4945254,-0.39313853,-0.5620741,0.29307356,0.02596003,-1.543947,0.53796583,-1.0612324,0.8722976,0.22701834,1.4152547,0.62690943,2.054118,-0.3432297,0.26089028,-0.6369734,2.2588098,0.47306576,1.301752,1.4933758,-0.80004513,0.9107707,0.61254835,-0.5136231,-2.0314925,0.026251614,0.06369413,-0.054635648,0.28420395,1.121271,1.9045366,-1.8284754,-0.22266579,-0.6138559,0.5645788,0.3998417,-0.8936077,-0.88701034,0.41881487,0.48932347,-1.8367976,-0.31449863,-0.106884085,-2.1406028,1.0445781,-0.8519579,0.4693373,1.2381319,0.12440759,1.4838173,1.7039821,-0.5250083,-1.4309396,-0.08591042,-0.991279,1.6855195,0.000010251999,-0.18572773,-0.19187139,0.06027895,0.18375634,0.33202925,-0.41924068,0.13084547,0.83971244,0.7759753,-0.21631937,-1.8269159,-0.12226879,-2.351196,0.26572856,-1.1403595,0.36859453,-0.27525464,-0.7434511,-0.12160298,-0.46814248,-1.2668463,1.0438665,0.045932807,0.34962952,-0.1021857,-1.2473536,-0.6456248,0.5553644,1.5830992,0.6742432,-0.57281816,0.25667277,-0.41252017,-0.073254414,0.08063067,0.01378614,-1.1421221,1.7499559,1.9508302,0.2585373,-0.39566475,-0.1916689,-1.9346781,-1.4051051,-0.30275637,0.99027765,-0.36612126,-1.1947212,-1.4714268,1.5775192,0.666944,0.24785258,-0.14280939,-0.5029461,0.09746343,-0.9176948,-0.35032004,-0.9154762,0.589031,-0.28047636,0.4622941,0.40380642,-1.6044255,0.41487852,-0.18119556,0.22922415,0.097508244,-0.79705787,0.94085085,-0.26617154,-1.4521791,1.3559406,-0.6104775,-0.08239315,1.6437706,0.28146446,0.2293791,0.005579131,0.19685626,-1.8483728,-0.1373314,0.53273886,-1.2362689,-0.98745227,-1.5254935,-1.4360377,-0.7536202,0.97018623,1.858938,1.6279092,-1.5310155,0.1481186,-0.056061678,-0.7383427,1.4934652,1.4408396,-0.53816754,-0.4913303,0.14130066,0.5321656,0.122391924,0.20193557,0.24566266,0.47194812,1.0622079,2.7710936,-0.20355758,-0.4141172,1.7278059,-0.437884,0.7103165,-1.6297998,-2.0117276,2.1802564,-0.7628883,-1.4479856,-0.64976305,0.3591741,-0.4918437,0.87851375,-0.45889515,-1.0719943,-0.0117326025,1.5461187,-0.7218995,-0.2574502,-0.7145093,-1.2038102,0.14999178,0.9184489,-0.68472564,0.5540621,-0.9437679,-0.79281276,-1.1875142,-0.67136097,-0.026134012,-0.2217994,0.08866367,-0.4162397,-0.7396491,-0.10942866,-1.4978706,-1.4594895,0.9817438,2.1016974,0.6259584,1.4601129,-0.25044045,1.1745733,-0.00009997329,2.1496668,-0.7583713,-0.06510508,0.9454804,-0.049515795,-1.0702795,0.1662055,-0.45352438,1.0704857,-0.9433599,-0.47983578,0.5817406,0.9755694]
        }
      },
      "boost": 1
    }
  },
  "min_score": 0.01,
  "_source": {
    "includes": [],
    "excludes": [
      "vec"
    ]
  },
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

接口响应信息:

{
  "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": "vec_face",
        "node": "3BWoFtg6SOaSKboaqW9q6g",
        "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日志堆栈信息:
3BWoFtg6SOaSKboaqW9q6g节点抓取到的完整堆栈日志信息:
 `shell
"stacktrace": ["org.elasticsearch.transport.RemoteTransportException: [es01][172.18.0.2:9300][indices:data/read/search[phase/query]]",
"Caused by: java.lang.NullPointerException",
"at org.elasticsearch.index.query.functionscore.ScriptScoreQueryBuilder.doRewrite(ScriptScoreQueryBuilder.java:176) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.AbstractQueryBuilder.rewrite(AbstractQueryBuilder.java:265) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:962) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:82) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:68) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:51) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.internal.ShardSearchLocalRequest$RequestRewritable.rewrite(ShardSearchLocalRequest.java:271) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.internal.ShardSearchLocalRequest$RequestRewritable.rewrite(ShardSearchLocalRequest.java:261) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:68) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createSearchContext(SearchService.java:638) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createSearchContext(SearchService.java:617) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createContext(SearchService.java:580) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:545) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:348) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.lambda$executeQueryPhase$1(SearchService.java:340) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListener.lambda$map$2(ActionListener.java:145) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:62) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.lambda$rewriteShardRequest$7(SearchService.java:1043) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionRunnable$1.doRun(ActionRunnable.java:45) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.4.0.jar:7.4.0]",
"at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]",
"at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]",
"at java.lang.Thread.run(Thread.java:830) [?:?]"] }
{"type": "server", "timestamp": "2019-12-24T08:13:31,164Z", "level": "DEBUG", "component": "o.e.a.s.TransportSearchAction", "cluster.name": "elasticsearch", "node.name": "es01", "message": "All shards failed for phase: [query]", "cluster.uuid": "p3I-WgFwS7i7krGQG8Em5g", "node.id":"3BWoFtg6SOaSKboaqW9q6g" ,
"stacktrace": ["org.elasticsearch.ElasticsearchException$1: null",
"at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:639) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:137) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:273) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.InitialSearchPhase.onShardFailure(InitialSearchPhase.java:105) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.InitialSearchPhase.access$200(InitialSearchPhase.java:50) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.InitialSearchPhase$2.onFailure(InitialSearchPhase.java:273) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:59) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:424) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1120) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1229) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1203) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:60) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.support.ChannelActionListener.onFailure(ChannelActionListener.java:56) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListener$1.onFailure(ActionListener.java:70) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:64) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.lambda$rewriteShardRequest$7(SearchService.java:1043) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionRunnable$1.doRun(ActionRunnable.java:45) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:773) [elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.4.0.jar:7.4.0]",
"at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]",
"at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]",
"at java.lang.Thread.run(Thread.java:830) [?:?]",
"Caused by: java.lang.NullPointerException",
"at org.elasticsearch.index.query.functionscore.ScriptScoreQueryBuilder.doRewrite(ScriptScoreQueryBuilder.java:176) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.AbstractQueryBuilder.rewrite(AbstractQueryBuilder.java:265) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:962) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.builder.SearchSourceBuilder.rewrite(SearchSourceBuilder.java:82) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:68) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:51) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.internal.ShardSearchLocalRequest$RequestRewritable.rewrite(ShardSearchLocalRequest.java:271) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.internal.ShardSearchLocalRequest$RequestRewritable.rewrite(ShardSearchLocalRequest.java:261) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.index.query.Rewriteable.rewrite(Rewriteable.java:68) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createSearchContext(SearchService.java:638) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createSearchContext(SearchService.java:617) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createContext(SearchService.java:580) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:545) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:348) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.search.SearchService.lambda$executeQueryPhase$1(SearchService.java:340) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListener.lambda$map$2(ActionListener.java:145) ~[elasticsearch-7.4.0.jar:7.4.0]",
"at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:62) ~[elasticsearch-7.4.0.jar:7.4.0]",
"... 9 more"] }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文