Hi ES Team,
I have a search query which is written in ES 2.14. How do I upgrade that query to version 8.X ? I am confused about how to alter the filter bool query(2.14) because its now filter context and not sure how to move the bool part of the filter to the query part.
Here is the original 2.14 query
"query":{
"bool":{
"{{#search}}must":{
"bool":{
"must":{
"bool":{
"minimum_should_match":1,
"should":[
{
"query_string":{
"fields":[
"act.{{lang}}{{#use_exact}}.exact{{/use_exact}}^6",
"act.{{lang}}.folded^6",
"title.{{lang}}{{#use_exact}}.exact{{/use_exact}}^10",
"title.{{lang}}.folded^10"
],
"boost":2,
"query":"{{query}}",
"analyze_wildcard":true,
"auto_generate_synonyms_phrase_query":true,
"default_operator":"AND",
"lenient":true,
"type":"phrase",
"tie_breaker":0
}
},
{
"query_string":{
"fields":[
"text.{{lang}}{{#use_exact}}.exact{{/use_exact}}",
"text.{{lang}}.folded^2",
"text.{{lang}}.shingles^4"
],
"query":"{{query}}",
"analyze_wildcard":true,
"auto_generate_synonyms_phrase_query":true,
"default_operator":"AND",
"lenient":true,
"minimum_should_match":1,
"type":"phrase"
}
}
]
}
},
"should":[
"{{#phrases}}",
{
"match":{
"text.{{lang}}.shingles":{
"query":"{{.}}",
"boost":4
}
}
},
"{{/phrases}}",
{
"match":{
"text.{{lang}}.shingles":{
"query":"{{terms}}",
"boost":2
}
}
}
],
"minimum_should_match":0
}
},
"{{/search}}filter":{
"bool":{
"must":[
"{{#result_search}}",
{
"query":{
"multi_match":{
"fields":[
"act.{{lang}}.folded^2",
"title.{{lang}}.folded^2",
"text.{{lang}}",
"text.{{lang}}.folded"
],
"query":"{{terms}}",
"zero_terms_query":"all"
}
}
},
"{{/result_search}}{{#sort_letter}}",
{
"prefix":{
"act.{{lang}}.prefix":"{{sort_letter}}"
}
},
"{{/sort_letter}}{{#source_pattern}}",
{
"regexp":{
"code":"{{source_pattern}}"
}
},
"{{/source_pattern}}{{#year}}",
{
"term":{
"year":"{{year}}"
}
},
"{{/year}}{{#pit_date}}",
{
"bool":{
"should":[
{
"bool":{
"must":[
{
"term":{
"state.{{lang}}":"historical"
}
},
{
"range":{
"dateFrom.{{lang}}":{
"lte":"{{pit_date}}"
}
}
},
{
"range":{
"dateTo.{{lang}}":{
"gte":"{{pit_date}}"
}
}
}
]
}
},
{
"bool":{
"must":[
{
"term":{
"state.{{lang}}":"current"
}
},
{
"range":{
"dateFrom.{{lang}}":{
"lte":"{{pit_date}}"
}
}
}
]
}
}
]
}
},
"{{/pit_date}}",
{
"terms":{
"state.{{lang}}":[
"{{#show_current}}",
"current",
"{{/show_current}}{{#show_rrs}}",
"rrs",
"{{/show_rrs}}",
"{{#state}}{{.}}{{/state}}"
],
"execution":"bool"
}
}
]
}
}
}
}