React SDK


The FilterBuilder class is used to construct filters for use with the relevant SearchProvider. They can later be referenced by the useFilter hook or Filter component.



The constructor accepts a single object with the following properties:

namestringThe name of the filter. This should be unique.
groupstringA group name, for grouping multiple filters together using ARRAY_MATCH.
fieldstringA field in schema, used if count = true.
optionsRecord<string, string \| () => string>Dictionary of name -> filter pairs.
initialstring | string[]List of initially selected items.
countbooleantrue if no options specified.Map to a field which aims to perform a count aggregate.
arraybooleanWhether the response of the field is an array. This setting is only applicable if count is set.
multibooleanMultiple selections allowed.
joinOperator'OR' | 'AND''OR'Join operator used if multi = true.


For more advanced implementations, you may want to access properties on the FilterBuilder instance.

listen(event: string, callback: (filter: FilterBuilder) => void)Register a listener for a specific event.
set(values: string[], merge: boolean = false)Set the state of the filter and optionally merge current values.
reset(emitEvent?: boolean)Reset the current filter to the initial one and optionally emit an event.
remove(values: string[])Remove a list of values from the current state.
isSet(name: string)Returns whether the filter is set or not.
setOptions(options: Options, merge: boolean = false)Set or merge filter options.
filter()Builds up the filter string from the current filter and it's children.
getBuckets()Get the bucket definitions for the filter.
getName()Returns the name property of the filter.
getGroup()Returns the group property of the filter.
getField()Returns the field property of the filter.
getCount()Returns the count property of the filter.
getOptions()Returns the current options property of the filter.
get()Returns the current selected options of the filter.
isArray()Returns the array property of the filter.
isMulti()Returns the multi property of the filter.

Listen example