BucketAggregation
BucketAggregation renders the list of search results aggregations as checkboxes.
By default it supports child aggregations. The user can select aggregations to filter results.
Usage
<BucketAggregation
title="Employee Types"
agg={{
field: "employee_type.type",
aggName: "type_agg",
childAgg: {
field: "employee_type.subtype",
aggName: "subtype_agg",
},
}}
/>
Props
title
StringThe title to display for the aggregation.
agg
ObjectAn object that describes the aggregation to look for in the
results:field
String: the field nameaggName
String: the aggregation name to look for inresultschildAgg
Object: a child aggregation with the same format as theaggprop
overridableId
StringoptionalAn optional string to define a specific overridable id.
Usage when overriding
const MyBucketAggregation = ({title, containerCmp}) => {
return (
<Menu vertical>
<Menu.Item>
<Menu.Header>{title}</Menu.Header>
{containerCmp}
</Menu.Item>
</Menu>
);
}
const BucketAggregationContainer = ({ valuesCmp }) => {
...
}
const MyBucketAggregationValues = ({ bucket, label, onFilterClicked, isSelected, childAggCmps }) => {
...
}
const overriddenComponents = {
"BucketAggregation.element": MyBucketAggregation,
"BucketAggregationContainer.element": MyBucketAggregationContainer,
"BucketAggregationValues.element": MyBucketAggregationValues,
};
BucketAggregation parameters
Component that wraps the bucket aggregations and renders a title and the container of aggregations.
title
StringThe title to render.
containerCmp
React componentThe
BucketAggregationContainerto render.agg
ObjectSame object as in the props.
updateQueryFilters
FunctionA function to call to update the current selected filters.
BucketAggregationContainer parameters
Component that wraps the list of aggregations.
valuesCmp
React componentList of components of each aggregation value.
BucketAggregationValues parameters
Component that renders each of the aggregation.
bucket
ArrayThe bucket to display, which by default contains the
keyfield with the value and thedoc_countnumber.label
StringThe label to display.
isSelected
Booleantrueif this value is active/selected,falseotherwise.onFilterClicked
FunctionThe function to be called when the user click on this value to activate the filter. It should be called with the
bucket.keyparameter.getChildAggCmps
FunctionA function to be called to render child component. It accepts the current
bucketas parameter and it will render recursively this component. It returns a list of child components.