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:
FROM detailed_table t
WHERE geohash_grid in
SELECT geohash_grid, COUNT()
FROM detailed_table t
GROUP BY geohash_grid
) < 3


Top hits:

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.