2015-09-10 65 views
0

我正嘗試使用邊界框過濾器過濾geohash聚合。但我有一個奇怪的錯誤:Parse Failure [Expected [FIELD_NAME] under a [START_OBJECT], but got a [START_OBJECT] in [traces]]];geo_bounding_box過濾器解析錯誤預計[FIELD_NAME]下的[START_OBJECT]

當我不使用此過濾器時,我的請求工作正常。

這裏是我的要求

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 

          } 
         } 
        } 
       } 
      } 
     } 
    } 
} 

這裏是我的映射的一部分,在那裏你可以看到的位置。

collections: [ { 
    name: 'traces', 
    index: 'traces', 
    type: 'trace', 
    mappings: { 
     'trace': { 
      'properties': { 
       'loc': { 
        'type': 'object', 
        'properties': { 
         'type': { 
          'type': 'string' 
         }, 
         'coordinates':{ 
          'type': 'geo_point', 
          'geohash':true, 
          'geohash_prefix':true, 
          'lat_lon':true, 
          'fielddata' : { 
           'format' : 'compressed', 
           'precision' : '1cm' 
          } 
         } 
        } 
       }, ..... 

我的要求有什麼問題?

回答

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 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
+0

何my ... Th Th you Val Val Val – dagatsoin

+0

沒有概率,很高興幫助!這麼多花括號,很容易迷路;-) – Val

相關問題