ExAliyunOts.Search.group_by_filter

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

group_by_filter(group_name, filters, options \\ [])

View Source

Specs

group_by_filter(group_name(), filters :: list(), options()) :: map()

On the query results, group by filters (they're Query usecase), and then get the number of matched filters, the order of the returned results is the same as that of the added filter(s).

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

Official document in Chinese | English

Example

import MyApp.TableStore

search "table", "index_name",
  search_query: [
    query: ...,
    group_bys: [
      group_by_filter(
        "group_name",
        [
          term_query("is_actived", true),
          range_query("price", from: 50)
        ]
      )
    ]
  ]

Options

  • :sub_group_bys, optional, add sub GroupBy type aggregations.
  • :sub_aggs, optional, add sub statistics.