I'm very new to elasticsearch.
I'm working on a UI that lets users compose queries by dragging UI widgets around. Sometimes they end up trying to run a search without having provided arguments, and the resulting search is logically empty. Is there a library or technique for taking a query and returning a new query with empty elements removed?
Here are a couple of examples of what our UI produces (based on user interaction). I believe those are both null queries. If there's not something built in, or some library for cleaning those up, is there a lexer/parser API that lets me process the query so I can clean it up myself?
{
"query": {
"bool": {
"must": [{
"bool": {
"must": [{
"bool": {
"must": []
}
}, {
"has_child": {
"type": "foo",
"query": {
"bool": {
"filter": [{
"range": {
"foo.date": {
"query": "",
"operator": "and"
}
}
}]
}
}
}
}]
}
}]
}
}
}
And here's another one:
{
"query": {
"bool": {
"must": [{
"bool": {
"must": [{
"bool": {
"must": []
}
}]
}
}]
}
}
}