I have to return an elasticsearch query in my code (Golang using olivere's elastic v.5 library) and if a particular condition occurs, I want to be able to pass in a query that will take minimal time and always return null. Is there a standard way to do this? I tried using a Term query with empty strings as parameters:
elastic.NewTermQuery("", "")
But this doesn't seem to be a valid query. Is there a good way to do this?
If by "always return null" you mean match nothing:
{
"bool": {
"must_not": {
"match_all": {}
}
}
}
I'm sure match_all is implemented very efficiently.