How to do that without regex?
Lets say I have a this doc in ES:
{
myField:""
}
MyField is text type (no keyword)
I have tried these:
"exists": {
"field": "myField",
}
"must_not":{
"term": {
"myField": {
"value": "",
}
}
}
But both returned the empty field.
The only solution which works for me is regex:
"must":{
"regexp": {
"myField": {
"value": ".*",
}
}
}
But regex usage can be performance heavy
Is there any solution to filter out non-empty text fields easily (without changing the mappings)?
You can try using range query and search values greater than empty string
{
"query": {
"range": {
"myField": {
"gt": ""
}
}
}
}