How to use the searchkit.AggsContainer function in searchkit

To help you get started, we’ve selected a few searchkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitodl / micromasters / static / js / components / search / WithReverseNestedAccessor.js View on Github external
buildSharedQuery(query: Object) {
      const modifiedQuery = super.buildSharedQuery(query)
      /**
       *  Modify query to perform aggregation on unique users,
       *  to avoid duplicate counts of multiple work histories or education items
       *  for the same user
       **/
      const pieces = nestedField.split(".")
      if (pieces.length !== 3) {
        throw new Error(`Assumed three pieces but found ${pieces.length}`)
      }

      const cardinality = CardinalityMetric("count", "user_id")
      const aggsContainer = AggsContainer(countName, { reverse_nested: {} }, [
        cardinality
      ])
      const termsBucket = TermsBucket(
        nestedField,
        nestedField,
        {},
        aggsContainer
      )

      const nestedBucket = NestedBucket(
        "inner",
        `${pieces[0]}.${pieces[1]}`,
        termsBucket
      )
      return modifiedQuery.setAggs(
        AggsContainer(
github mitodl / micromasters / static / js / components / search / NestedAggregatingMenuFilter.js View on Github external
function ReverseNestedTermsBucket(key, field, options) {
  const reverseNestedAgg = AggsContainer(REVERSE_NESTED_AGG_KEY, {
    reverse_nested: {}
  })
  return TermsBucket(key, field, options, reverseNestedAgg)
}
github mitodl / micromasters / static / js / components / search / WithReverseNestedAccessor.js View on Github external
cardinality
      ])
      const termsBucket = TermsBucket(
        nestedField,
        nestedField,
        {},
        aggsContainer
      )

      const nestedBucket = NestedBucket(
        "inner",
        `${pieces[0]}.${pieces[1]}`,
        termsBucket
      )
      return modifiedQuery.setAggs(
        AggsContainer(
          `${this.uuid}`,
          {
            filter: {}
          },
          [nestedBucket]
        )
      )
    }