Reputation: 511
Elasticsearch enable you to query multiple indices on fields that exists or not on those indices.
But when querying on multiple indices with the geo_bounding_box elastic throws exception if the queried fields not exists in all requested indices.
it seems that elastic check if the required fields are mapped as geo-point.
Is there a way to achieve this query without editing mapping and adding all geo_fileds in all indecies?
Upvotes: 0
Views: 516
Reputation: 217554
You could use the indices
query in a bool/should
arrangement like below. This way you don't run the risk of querying an index with the wrong field name:
POST /indexA,indexB/_search
{
"query": {
"bool": {
"should": [
{
"indices": {
"indices": [
"indexA"
],
"query": {
"geo_bounding_box": {
"x_location": {...} }
}
}
},
{
"indices": {
"indices": [
"indexB"
],
"query": {
"geo_bounding_box": {
"y_location": {...}
}
}
}
}
]
}
}
}
Upvotes: 1