I just built a Java action to do the job.
Other solution would be to first build the json for the filter yourself in a microflow as a string and then use an export mapping? This, of course, needs some logic in your microflow but should be possible (with the modelreflection if needed).
you are pushing me :-) My complete JSON is below. It consists of four distinct parts: query (query.bool.must), domain (query.bool.filter.bool), facets (query.bool.filter.multi_match[]), and optional aggregation at the bottom. So, if I go the ExtractMapping route, I will need to build four extract maps and then do string massaging; the nasty one to marry domain and facets. Since I already wrote the Java action I was simply lazy enough to rewrite it using maps followed by inevitable string massaging.
{
"query": {
"bool": {
"must": [
{ "query_string": {
"query": "ACME",
"fields": ["AccountName","AccountNumber"]
}
}
],
"filter": [
{
"bool": {
"should": [
{ "multi_match": { "fields": ["Country"], "query": "US"} },
{ "multi_match": { "fields": ["Country"], "query": "CA"} }
]
}
},
{ "multi_match": {"fields": ["Status"],"query": "Active"}},
{ "multi_match": {"fields": ["BillToPrimary"],"query": "Y"}}
]
}
},
"size": 100,
"aggs":{
"langs": {
"terms": {
"field": "CustomerID",
"size": 1000
}
}
}
}