ElasticSearch Malform Qquery

时间:2018-01-05 17:54:48

标签: elasticsearch

我在ElasticSearch 5.5中执行以下聚合查询时," [必须]查询格式错误,查询名称后没有start_object" 。任何的想法?

curl -XGET 'localhost:9200/car/car/_search?pretty' -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool": {
      "must": { "match": { "car_color": "Yellow" }  }
    }
  },
  "aggregations": {
      "all_cars": {
         "global": {},
         "aggregations": {
            "car_makes": {
               "filter": {
                  "must": [
                     {
                        "terms": {"car_color": ["Yellow"]}
                     }
                  ]
               },
               "aggregations": {
                  "filtered_car_make": {
                     "terms": {"field": "car_make"}
                  }
               }
            }
         }
      }
   }
}
'

2 个答案:

答案 0 :(得分:0)

您是否尝试过不在bool查询中的匹配查询?

{
  "query": {
    "match": { "car_color": "Yellow" }
   },
   "aggregations": {
     ....
}

答案 1 :(得分:0)

问题出在聚合过滤器

           "filter": {
              "must": [
                 {
                    "terms": {"car_color": ["Yellow"]}
                 }
              ]
           },

需要像这样修复:

           "filter": {
               "terms": {"car_color": ["Yellow"]}
           },