I'm trying to do a geospatial searce, since I can get multiple hits with the same listing_id I'd like to group the results by the listing_id.
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "24km",
"location":[39.91774, -75.03005]
}
}
},
"aggs": {
"group_by_listing": {
"terms": { "field": "listing_id" }
}
}
}
If I search without the aggregation the results come back fine, but whenever I try adding an aggregation node I receive the following error
{"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}
This is the curl request:
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"}}}}}'