Elasticsearch模板无法读取ID中的下划线

时间:2018-09-12 09:21:18

标签: elasticsearch mustache elastic-stack elasticsearch-template

这是我的查询模板,该模板是小胡子-

{\"query\":{\"ids\":{\"type\":\"component\",\"values\":[{{#id_list1}}{{value}}{{#comma}},{{/comma}}{{/id_list1}}]}},\"size\":{{#size}}{{size}}{{/size}}{{^size}}200{{/size}}}{{/id_list}}

在值中,当我传递诸如“ 1110,1111,1123”甚至“ 1110”之类的值时,它可以正常工作,但是当我尝试传递诸如“ 1110_media”之类的值时,它给我一个错误,

"type": "parsing_exception",
        "reason": "[ids] failed to parse field [values]",
        "line": 1,
        "col": 47,
        "caused_by": {
            "type": "json_parse_exception",
            "reason": "Unexpected character ('_' (code 95)): was expecting comma to separate Array entries\n at [Source: {\"query\":{\"ids\":{\"type\":\"component\",\"values\":[1110_media]}},\"size\":200}; line: 1, column: 52]"
        }
    }, 

当我尝试不使用模板进行搜索时,它给了我想要的结果,例如-

{"query":{"ids":{"type":"component","values":["1110_media","1110"]}},"size":200}

我们如何转义带有下划线的数组值?

0 个答案:

没有答案