You're seeing just the function group_by_geo_distance, go back to ExAliyunOts.Search module for more information.
Link to this function

group_by_geo_distance(group_name, field_name, ranges, options \\ [])

View Source


group_by_geo_distance(group_name(), field_name(), ranges :: list(), options()) ::

The query results are grouped according to the range from a certain center Geo point, if the distance difference is within a certain range, it will be put into a group, and finally the number of corresponding items in each range will be returned.

We can set it in the nested :group_bys option of :search_query option in ExAliyunOts.search/4.

Official document in Chinese | English


import MyApp.TableStore

search "table", "index_name",
  search_query: [
    query: ...,
    group_bys: [
      group_by_geo_distance("test", "location",
          {0, 100_000},
          {100_000, 500_000},
          {500_000, 1000_000},
        lon: 0,
        lat: 0,
        sub_aggs: [
          agg_sum("test_sum", "value")


  • :lon, required, the longitude of the origin center point, integer or float.
  • :lat, required, the latitude of the origin center point, integer or float.
  • :sub_group_bys, optional, add sub GroupBy type aggregations.
  • :sub_aggs, optional, add sub statistics.