小编Sve*_*ann的帖子

ElasticSearch 无痛,如何访问 _source 中的数组

我尝试对 ElasticSearch (6.4.0) API 执行搜索请求,其中包含自定义脚本函数。在此函数中,我尝试访问一个数组,该数组应该是响应数据的一部分。但我总是得到一个“null_pointer_exception”:

{
"error": {
    "root_cause": [
        {
            "type": "script_exception",
            "reason": "runtime error",
            "script_stack": [
                "i = 0; i < params['_source']['userStats'].length; i++) { } ",
                "                 ^---- HERE"
            ],
            "script": "double scoreBoost = 1; for (int i = 0; i < params['_source']['userStats'].length; i++) { } return _score * Math.log1p(scoreBoost);",
            "lang": "painless"
        }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
        {
            "shard": 0,
            "index": "search--project",
            "node": "...",
            "reason": {
                "type": "script_exception",
                "reason": …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

5
推荐指数
1
解决办法
7170
查看次数

标签 统计

elasticsearch ×1