Elasticsearch template unable to read underscore in ids

201 Views Asked by At

Here is my query template which is mustache-

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

In values when I passing values such as "1110,1111,1123" or even "1110" it is working correctly but when I am trying to pass value such as "1110_media" it is giving me an error,

"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]"
        }
    }, 

It is giving me desired results when I try to search without using template,for example-

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

How can we escape array values having underscore?

0

There are 0 best solutions below