If you make a search request with a geo_bounding_box query, it will fail with a QueryShardException with message failed to find geo field [my-field] in the case where the index doesn't have a mapping for my-field. However, if you try other queries such as terms, it will not fail if you execute it over a field that is not defined in the mapping; it will just return no result.
What should I do to make the geo_bounding_box query behave like the terms query in the case the index is missing a mapping for the field ?
Have you tried using the "exists" method? This method checks if a specific field exists in a document before executing the query. Here is an example of how you can adapt your query:
It works but I think it's cumbersome having to put the exists query. There may be other queries that have the same issue with missing fields; we'd have to pair every query with an exists query then.
For example, this can become very complex in bool queries with a should clause. Consider the following with a "natural" expression:
I think the "natural" expression of the should clause is better. The exists query fix works for simple cases, but it doesn't seem to scale to more complex ones.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.