简体   繁体   English

Elasticsearch脚本查询不起作用

[英]Elasticsearch script query not working

I'm using script to exclude search result, but it doesn't work as expected. 我正在使用脚本排除搜索结果,但无法按预期工作。 I check all data in the index , the selluserid have value null and 0 . 我检查索引中的所有数据, selluserid值为null和0。

{
  "script": {
            "script": {
              "inline": "(doc['isshoper'].value == 0) || params.arrShopUser.get(doc['selluserid'].value.toString())",
              "params": {
                "arrShopUser": {
                  "95794": true,
                  "214214": true,
                  "329221": true,
                  "8888": true,
                  "373502": true,
                  "309235": true,
                  "383247": true,
                  "383252": true,
                  "9999": true,
                  "637312": true,
                  "642158": true,
                  "445055": true,
                  "444214": true,
                  "821435": true,
                  "1111": true,
                  "2222": true,
                  "6666": true,
                  "7777": true,
                  "4444": true,
                  "666": true,
                  "777": true,
                  "222": true,
                  "333": true,
                  "555": true,
                  "888": true,
                  "66633": true,
                  "1991944": true,
                  "1991949": true,
                  "1991941": true,
                  "1992000": true,
                  "1992019": true,
                  "1992023": true,
                  "1992046": true,
                  "1992068": true,
                  "1992006": true,
                  "1992055": true
                }
              }
            }
          }
        }

error message 错误信息

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "(doc['isshoper'].value == 0) || params.arrShopUser.get(doc['selluserid'].value.toString())",
          "                                                                              ^---- HERE"
        ],
        "script": "(doc['isshoper'].value == 0) || params.arrShopUser.get(doc['selluserid'].value.toString())",
        "lang": "painless"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "tsy_trade",
        "node": "1MbSaY-RR6GPgo_AI-g8GA",
        "reason": {
          "type": "script_exception",
          "reason": "runtime error",
          "script_stack": [
            "(doc['isshoper'].value == 0) || params.arrShopUser.get(doc['selluserid'].value.toString())",
            "                                                                              ^---- HERE"
          ],
          "script": "(doc['isshoper'].value == 0) || params.arrShopUser.get(doc['selluserid'].value.toString())",
          "lang": "painless",
          "caused_by": {
            "type": "null_pointer_exception",
            "reason": null
          }
        }
      }
    ]
  },
  "status": 500
}

尝试使用以下脚本:

(doc['isshoper'].value == 0) || (doc['isshoper'].value == null) || params.arrShopUser.get(doc['selluserid'].value.toString())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM