How to make map clustering through elastic search more flexible?

I am developing an interactive map and my technology stack includes NodeJS, Angular, MapBox, and Elasticsearch. My application is a complex data aggregator, and I am trying to cluster my data on the map using Elasticsearch.

To understand my problem, let me briefly describe the situation. In Elasticsearch, users are stored as documents, and each user has a location field, which is a nested type (meaning that a user can have multiple locations).

On the map, I want to display all user locations along with the number of users in each location. For example, if a user has locations in both Brazil and Italy, their doc_count should be included in both Brazil and Italy.

Here is where the clustering problem arises. To maintain the correct doc_count for each location, I cannot use any client-side clustering libraries (such as SuperCluster), as they would not be able to accurately calculate the doc_count if a person has multiple locations. For example, if a person has locations in both Switzerland and France, and the map is zoomed out, these two countries would merge into one cluster, which would not have the correct doc_count value.

Therefore, I can only use the capabilities of Elasticsearch itself. My choice was to use the geo_tile aggregation with a nested geo_centroid aggregation, which solved the doc_count problem and always showed the correct values. However, because geo_tile is not a flexible tool, points on the map became too close to each other (for example, points that exist on the boundary of two tiles).

I started looking for a solution that would allow for more flexible clustering without being tied to tiles or a grid. I found a plugin (GitHub - opendatasoft/elasticsearch-aggregation-geoclustering: An Elasticsearch plugin to aggregate Geo Points in clusters.) that did exactly what I needed (especially the ability to specify a radius), but it hasn't been updated in a long time and isn't officially supported. This would be a big bottleneck if I installed it on my project.

Can anyone recommend a ready-made solution to my problem? Perhaps a supported plugin or a solution using the already established tools in Elasticsearch?

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