How to use the searchkit.FilterBucket 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 searchkit / searchkit-demo / src / app / src / crime / CrimeAggs.tsx View on Github external
buildOwnQuery(query){
    return query.setAggs(FilterBucket(
      "geo", query.getFilters(),
      GeohashBucket(
        "areas", "location",
        {precision:this.precision, size:100},
        GeoBoundsMetric("cell", "location")
      ),
      SignificantTermsBucket("significant","crime_type.raw", {size:2}),
      GeoBoundsMetric("bounds", "location")
    ))
  }
}
github searchkit / searchkit / packages / searchkit-autosuggest / src / datasources / QuickHitsDatasource.ts View on Github external
search(query, queryString) {
        return query.setAggs(
            FilterBucket(
                this.options.id, MultiMatchQuery(queryString, {
                    type: "phrase_prefix",
                    fields: this.options.searchFields
                }),
                TopHitsMetric('tophits', {
                    size: this.options.size,
                    _source: this.options.searchFields
                })
            )
        )
    }
github mitodl / micromasters / static / js / components / search / FinalGradeRangeFilter.js View on Github external
getRangeBucket(query) {
    const otherAppliedFiltersOnPath = this.createFilterForOtherElementsOnPath(
      query
    )
    const rangeBucket = this.createInnerRangeBucket()
    if (otherAppliedFiltersOnPath) {
      return FilterBucket(this.key, otherAppliedFiltersOnPath, rangeBucket)
    } else {
      return rangeBucket
    }
  }
github mitodl / micromasters / static / js / components / search / NestedAggregatingMenuFilter.js View on Github external
termsKey,
      this.key,
      _.omitBy(
        {
          size:          this.size,
          order:         this.getOrder(),
          include:       this.options.include,
          exclude:       this.options.exclude,
          min_doc_count: this.options.min_doc_count
        },
        _.isUndefined
      )
    )

    if (otherAppliedFiltersOnPath) {
      return FilterBucket(this.key, otherAppliedFiltersOnPath, termsBucket)
    } else {
      return termsBucket
    }
  }
github CRUKorg / cruk-searchkit / src / components / search / date / CRUKSearchkitDateRangeAccessor.jsx View on Github external
const min = val.min;
    const max = val.max;

    let otherFilters = query.getFiltersWithoutKeys(this.key);
    let filters = BoolMust([
      otherFilters,
      RangeQuery(this.options.field,{
        gte:min,
        lt: this.addOneDay(val.max),
        format: 'yyyy-MM-dd'
      })
    ]);

    const metric = CardinalityMetric(this.key, this.options.field);

    return query.setAggs(FilterBucket(
      this.key,
      filters,
      metric
    ));
  }
}
github CRUKorg / cruk-searchkit / src / components / search / location / CRUKSearchkitLocationAccessor.jsx View on Github external
buildOwnQuery(query) {
    let filters = query.getFilters()
    if (!this.state.getValue()){
      if (filters) filters = BoolMust([filters, this.filter])
      else filters = this.filter
    }
    return query
      .setAggs(FilterBucket(
        this.key,
        filters
      ))
  }
}
github searchkit / searchkit-demo / src / app / src / playground / accessors / NumericOptionsAccessor.ts View on Github external
buildOwnQuery(query) {
    return query.setAggs(FilterBucket(
      this.key,
      query.getFiltersWithoutKeys(this.uuid),
      RangeBucket(
        this.key,
        this.options.field,
        this.getRanges()
      )
    ))
  }
github gaving / searchkit-geomap / src / GeoAccessor.js View on Github external
buildOwnQuery(query) {
    return query.setAggs(
      new FilterBucket(
        'geo',
        query.getFilters(),
        new GeohashBucket('areas', 'location', {}, new GeoBoundsMetric('cell', 'location')),
        {},
        new GeoBoundsMetric('bounds', 'location')
      )
    );
  }
}
github searchkit / searchkit-examples / searchkit-starter-react16 / src / components / SearchkitAutosuggest / datasources / QuickHitsDatasource.js View on Github external
search(query, queryString){
        return query.setAggs(
            FilterBucket(
                this.options.id, MultiMatchQuery(queryString,{
                    type:"phrase_prefix",
                    fields:["title"]
                }), 
                TopHitsMetric('tophits', {
                    size:3, 
                    _source:['title', 'imdbId']
                })            
            )
        )
    }