May be is a very stupid question, What is the best way to check if a field of a document in elasticsearch exists? I can\'t find anything in the documentation.
For ex
You can use the exists filter combined with a bool/must filter like this:
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"exists": {
"field": "price"
}
},
... <-- your other constraints, if any
]
}
}
}
}
}
DEPRECATED (since ES5) You can also use the missing filter combined with a bool/must_not filter:
{
"query": {
"filtered": {
"filter": {
"bool": {
"must_not": [
{
"missing": {
"field": "price"
}
}
]
}
}
}
}
}