geo_bounding_box过滤器解析错误[START_OBJECT]下的预期[FIELD_NAME]

时间:2015-09-10 22:12:37

标签: elasticsearch

我正在尝试使用边界框过滤器过滤geohash聚合。但我有一个奇怪的错误:foreach(IParameterReturnable parameter in stackPanel.Children) { string val = parameter.GetValue() // <= this will always return the default value }

当我不使用此过滤器时,我的请求正常。

这是我的要求

Parse Failure [Expected [FIELD_NAME] under a [START_OBJECT], but got a [START_OBJECT] in [traces]]];

以下是我的地图的一部分,您可以在其中查看位置。

POST /traces/_search?search_type=count&pretty
{
    "aggregations": {
        "traces": {
            "filter": {
                "or": [{
                    "and": [
                      {"term": {"geoip": true}},
                      {"term": {"trackerId": "RG-000000003-1"}}]
                }],
                "geo_bounding_box" : {
                  "loc.coordinates" : {
                      "top_left" : {
                        "lat": 49.109837790524416,
                        "lon": 14.326171874999998
                      },
                      "bottom_right" : {
                          "lat": 44.05601169578525,
                          "lon": -9.404296875
                      }
                  }
              }
            },
            "aggregations": {
                "trackerId": {
                    "terms": {
                        "field": "trackerId",
                        "size": 0
                    },
                    "aggregations": {
                        "heatmap": {
                            "geohash_grid": {
                                "field": "loc.coordinates",
                                "precision": 1

                            }
                        }
                    }
                }
            }
        }
    }
}

我的要求有什么问题?

1 个答案:

答案 0 :(得分:0)

问题在于geo_bounding_box过滤器位于or过滤器之外。只需像这样重写您的查询:

{
  "aggregations": {
    "traces": {
      "filter": {
        "or": [
          {
            "and": [
              {
                "term": {
                  "geoip": true
                }
              },
              {
                "term": {
                  "trackerId": "RG-000000003-1"
                }
              }
            ]
          },
          {
            "geo_bounding_box": {      <--- this need to go inside the "or" array
              "loc.coordinates": {
                "top_left": {
                  "lat": 49.109837790524416,
                  "lon": 14.326171874999998
                },
                "bottom_right": {
                  "lat": 44.05601169578525,
                  "lon": -9.404296875
                }
              }
            }
          }
        ]
      },
      "aggregations": {
        "trackerId": {
          "terms": {
            "field": "trackerId",
            "size": 0
          },
          "aggregations": {
            "heatmap": {
              "geohash_grid": {
                "field": "loc.coordinates",
                "precision": 1
              }
            }
          }
        }
      }
    }
  }
}