Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
}
}
(
<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>
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
}
}
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
));
}
<div>
<div>
{/*<button>Click to refresh</button>*/}
</div></div>
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
))
}
}
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
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
}