我试图做一个地理空间搜索,因为我可以使用相同的listing_id获得多个点击,我想按listing_id分组结果。
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "24km",
"location":[39.91774, -75.03005]
}
}
},
"aggs": {
"group_by_listing": {
"terms": { "field": "listing_id" }
}
}
}如果我在没有聚合的情况下进行搜索,结果就会很好地返回,但是每当我尝试添加聚合节点时,我都会收到以下错误{"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse search source. expected field name but got [START_OBJECT]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"listings","node":"n0nkglP4T6iik-Z-XyYspA","reason":{"type":"parse_exception","reason":"failed to parse search source. expected field name but got [START_OBJECT]"}}]},"status":400}
这是curl请求:curl -XPOST http://192.168.10.10:9200/listings/route/_search -d '{"query":{"filtered":{"filter":{"geo_distance":{"distance":"24km","location":[39.91774, -75.03005]}}},"aggs":{"group_by_listings":{"terms":{"field":"listing_id"}}}}}'
发布于 2016-06-05 06:01:15
只需将aggs移出query部件,如下所示:
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "24km",
"location": [
39.91774,
-75.03005
]
}
}
}
},
"aggs": {
"group_by_listing": {
"terms": {
"field": "listing_id"
}
}
}
}https://stackoverflow.com/questions/37634977
复制相似问题