How can I retrieve the detailed doc matching the aggregation rule?

Well, I have a index for the detailed docs, the fields are like this: the house's geo_point, the house's name.
With a geohash_grid aggregation, I can retrieve those geohash_grids and how many houses within it.

However, I want to see the exact house's information(the detailed ones) for the geohash_grid buckets which contain less than 3 houses.

in SQL-like format, that query will be like this:
SELECT *
FROM detailed_table t
WHERE geohash_grid in
(
SELECT geohash_grid, COUNT()
FROM detailed_table t
GROUP BY geohash_grid
HAVING COUNT(
) < 3
);

thanks:)

Top hits: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html

1 Like

great! that's what I want :stuck_out_tongue:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.