Elasticsearch使您可以查询那些索引上存在或不存在的字段上的多个索引。
但是当使用geo_bounding_box查询多个索引时,如果查询的字段在所有请求的索引中都不存在,则 flex 抛出异常。
似乎可以 flex 检查是否将必填字段映射为地理位置。
有没有一种方法可以实现此查询而无需编辑映射并在所有索引中添加所有geo_fileds?
最佳答案
您可以按如下所示的indices
安排使用 bool/should
query。这样,您就不会冒用错误的字段名查询索引的风险:
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": {...}
}
}
}
}
]
}
}
}
关于elasticsearch - Elasticsearch多索引查询与地理边界框查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39062593/