How to use the searchkit.BoolMust 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 / util.js View on Github external
const allFilters = this.getAllFiltersOnPath(query)
      let otherFilters = []
      if (allFilters.length > 0) {
        // Only keep the filters for other elements on this nested path
        otherFilters = R.filter(
          R.compose(
            R.not,
            R.equals(this.getFieldKey()),
            R.head,
            R.keys,
            R.head,
            R.values
          )
        )(allFilters)
      }
      return otherFilters.length > 0 ? BoolMust(otherFilters) : undefined
    }
  }
github searchkit / searchkit / packages / searchkit-e2e-tests / src / apps / playground / index.tsx View on Github external

              
              
               (
                  
                        <option value="list">List</option>
                        <option value="checkbox">Checkbox</option>
                        <option value="histogram">Histogram</option>
                        <option value="select">Select</option>
                        <option value="tabs">Tabs</option>
github mitodl / micromasters / static / js / components / search / util.js View on Github external
createGroupedNestedFilter(query, filterToAdd) {
      const nestedPath = this.getNestedPath()
      const appliedFiltersOnPath = query.getFiltersWithKeys([nestedPath])
      if (_.isEmpty(appliedFiltersOnPath)) {
        return this.fieldContext.wrapFilter(filterToAdd)
      } else {
        let mustFilters = []
        const nestedFilter = _.get(appliedFiltersOnPath, ["nested", "query"])
        if (nestedFilter.bool) {
          mustFilters = _.get(nestedFilter, ["bool", "must"])
        } else {
          mustFilters = [nestedFilter]
        }
        mustFilters.push(filterToAdd)
        _.set(appliedFiltersOnPath, ["nested", "query"], BoolMust(mustFilters))
        return appliedFiltersOnPath
      }
    }
github CRUKorg / cruk-searchkit / src / components / search / date / CRUKSearchkitDateRangeAccessor.jsx View on Github external
buildOwnQuery(query) {
    const val = this.state.getValue();
    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 searchkit / searchkit-demo / src / app / src / playground / PlaygroundApp.tsx View on Github external
<div>

            <div>
              {/*<button>Click to refresh</button>*/}
              
                
              
              
              
              
              
              
              
              
              
                
              
              </div></div>
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 / packages / searchkit-autosuggest / src / datasources / HierarchicalRefinementDatasource.ts View on Github external
search(query, queryString) {
        const { field, startLevel } = this.delegateAccessor.options
        const regexpQuery = {
            regexp: {
                [field + ".value"]: createRegexQuery(queryString)
            }
        }
        return query.setAggs(FilterBucket(
            this.delegateAccessor.uuid,
            BoolMust([
                NestedQuery(field, regexpQuery)
            ]),
            NestedBucket("children", field,
                FilterBucket("filtered",
                    BoolMust([
                        regexpQuery,
                        {
                            "range": {
                                [field + ".level"]: {
                                    gte: startLevel
                                }
                            }
                        }
                    ]),
                    TermsBucket("terms", field + ".value", {
                        size: this.options.size
github mitodl / micromasters / static / js / components / search / util.js View on Github external
createAggFilter(query) {
      const filters = []
      const nestedPath = this.getNestedPath()
      const unrelatedFilters = query.getFiltersWithoutKeys(nestedPath)
      if (unrelatedFilters) {
        filters.push(unrelatedFilters)
      }
      const otherAppliedFiltersOnPath = this.createFilterForOtherElementsOnPath(
        query
      )
      if (otherAppliedFiltersOnPath) {
        filters.push(NestedQuery(nestedPath, otherAppliedFiltersOnPath))
      }
      return filters.length > 0 ? BoolMust(filters) : undefined
    }