首页 > 解决方案 > 根映射定义在运行弹性搜索无痛脚本时具有不受支持的参数(mapper_parsing_exception)

问题描述

{
    "query": {
        "match_all": {}
    },
    "script": {
        "source":"if(ctx._source.containsKey('priority')){if (ctx._source.priority != null && ctx._source.priority != 'null') { ctx._source.priority_filter  =  String.valueOf(ctx._source.priority) } else { ctx._source.priority_filter = ''}}",
        "lang": "painless"
        
    }
}

当我尝试运行上述脚本时出现以下错误,谁能告诉我哪里出错了,我的弹性搜索版本是v6.5.2

{
        "error": {
            "root_cause": [
                {
                    "type": "mapper_parsing_exception",
                    "reason": "Root mapping definition has unsupported parameters:  [query : {match_all={}}] [script : {source=if(ctx._source.containsKey('priority')){if (ctx._source.priority != null && ctx._source.priority != 'null') { ctx._source.priority_filter  =  String.valueOf(ctx._source.priority) } else { ctx._source.priority_filter = ''}}, lang=painless}]"
                }
            ],
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [query : {match_all={}}] [script : {source=if(ctx._source.containsKey('priority')){if (ctx._source.priority != null && ctx._source.priority != 'null') { ctx._source.priority_filter  =  String.valueOf(ctx._source.priority) } else { ctx._source.priority_filter = ''}}, lang=painless}]"
        },
        "status": 400
    }

标签: elasticsearchelasticsearch-scripting

解决方案


推荐阅读