elasticsearch - Elasticsearch多索引查询与地理边界框查询

标签 elasticsearch

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/

相关文章:

java - 使用elasticsearch为Oracle等现有关系数据库建立索引

c# - ElasticSearch 查询结果是否缓存?

elasticsearch - Elasticsearch-如何在一个字符串中搜索多个单词

java - 如何使用 Elastic 对最后的 Null 进行排序?

angular - 我无法连接到Google Cloud Platform中的 Elasticsearch

php - 在elasticsearch中是否可以只使用过滤器而不使用文本搜索

arrays - 通过比较数组进行ElasticSearch 5.1过滤

Elasticsearch:按单词和点分割的自定义标记器

elasticsearch - 使用简单查询字符串查询的前缀通配符

python - Scrapy - 数据库选择