Is it possible to filter by a scripted field? If so, how would the query look like?
I tried using the scripted field in a post_filter but it dies silently (0 matches)
The goal is to derive a new field as a predicate based on an existing field, and then filter on it based a condition...
GET /concession_test/_search
{
"_source": ["ref_nr","material_text_en"],
"script_fields":{
"test_pred_1":{
"script":{
"lang":"painless",
"source":"if(params._source.material_text_en.contains("TASK_1") || params._source.material_text_en.contains("QUEUE_1") || params._source.material_text_en.contains("TEST_1")){ return true } else { return false }"
}
}
},
"post_filter": {
"term": { "test_pred_1": true }
}
}
Thanks!