we are using Mustache script in the query to use params, since script contains Pattern
and painless doesn't support parameterizing Pattern
.
query:
PUT test_index/notification/ID
{
"source": {
"query": {
"bool": {
"must": [
{
"bool": {
"must": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"query_string": {
"query": "a*",
"quote_analyzer": "standard",
"allow_leading_wildcard": "true",
"analyze_wildcard": "true",
"default_operator": "AND",
"phrase_slop": 1
}
},
{
"script": {
"script": {
"source": "Pattern p = {{param_0}}; p.matcher(params._source.summary ?: '').find();",
"lang": "painless"
}
}
}
]
}
}
]
}
}
}
}
]
}
},
"sort": [
{
"headline.case_insensitive_sort_raw": "asc"
}
]
},
"params": {
"param_0": "/\\s?a\\S*?/i"
}
}
and percolator search is:
GET test_index/_search
{
"query": {
"percolate": {
"field": "query",
"document_type": "doctype",
"index": "document_index_testing",
"type": "mediaitems",
"id": "262587721"
}
}
}
and it is not matching. If the percolator query using painless
, it works fine.
is there any way to make Mustache
script works in Percolator