NumericFacet (Insight Engine)
NumericFacet (Insight Engine)
|
|
Note
This component was introduced in version |
The NumericFacet controller makes it possible to create a facet with numeric ranges.
Methods
deselectAll
Deselects all facet values.
disable
Disables the facet. That is, prevents it from filtering results.
enable
Enables the facet. That is, undoes the effects of disable.
isSortedBy
Checks whether the facet values are sorted according to the specified criterion.
Parameters
-
criterion:
'ascending' | 'descending'The criterion to compare.
Returns boolean: Whether the facet values are sorted according to the specified criterion.
isValueSelected
Checks whether the specified facet value is selected.
Parameters
-
selection:
NumericFacetValueThe facet value to check.
Returns boolean: Whether the specified facet value is selected.
sortBy
Sorts the facet values according to the specified criterion.
Parameters
-
criterion:
'ascending' | 'descending'The criterion to sort values by.
toggleSelect
Toggles the specified facet value.
Parameters
-
selection:
NumericFacetValueThe facet value to toggle.
toggleSingleSelect
Toggles the specified facet value, deselecting others.
Parameters
-
selection:
NumericFacetValueThe facet value to toggle.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => voidA callback that’s invoked on state change.
Returns Unsubscribe: A function to remove the listener.
Attributes
state
The state of the NumericFacet controller.
Properties
-
enabled:
booleanWhether the facet is enabled and its values are used to filter search results.
-
facetId:
stringThe facet ID.
-
hasActiveValues:
booleantrueif there is at least one non-idle value andfalseotherwise. -
isLoading:
booleantrueif a search is in progress andfalseotherwise. -
sortCriterion:
'ascending' | 'descending'The active sortCriterion of the facet.
-
values:
NumericFacetValue[]The values of the facet.
Initialize
buildNumericFacet
Creates an insight NumericFacet controller instance.
Parameters
-
engine:
InsightEngineThe insight engine.
-
props:
NumericFacetPropsThe configurable
NumericFacetproperties.
Returns NumericFacet
NumericFacetProps
The configurable NumericFacet properties.
Properties
-
options:
NumericFacetOptionsThe options for the
NumericFacetcontroller.
NumericFacetOptions
The options for the NumericFacet controller.
Properties
-
field:
stringThe field whose values you want to display in the facet.
-
generateAutomaticRanges:
booleanWhether the index should automatically create range values.
Tip: If you set this parameter to true, you should ensure that the 'Use cache for numeric queries' option is enabled for this facet’s field in your index in order to speed up automatic range evaluation.
-
currentValues?:
NumericRangeRequest[]The values displayed by the facet in the search interface at the moment of the request.
If
generateAutomaticRangesis false, values must be specified. IfgenerateAutomaticRangesis true, automatic ranges are going to be appended after the specified values.Default:
[] -
facetId?:
stringA unique identifier for the controller. By default, a unique random identifier is generated.
-
filterFacetCount?:
booleanWhether to exclude folded result parents when estimating the result count for each facet value.
Default:
true -
injectionDepth?:
numberThe maximum number of results to scan in the index to ensure that the facet lists all potential facet values.
Note: A high injectionDepth may negatively impact the facet request performance.
Minimum:
0Default:
1000 -
numberOfValues?:
numberThe number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.
Minimum:
1Default:
8 -
rangeAlgorithm?:
'even' | 'equiprobable'The algorithm that’s used for generating the ranges of this facet when they aren’t manually defined. The default value of
"even"generates equally sized facet ranges across all of the results. The value"equiprobable"generates facet ranges which vary in size but have a more balanced number of results within each range.Default:
even -
resultsMustMatch?:
FacetResultsMustMatchThe criterion to use for specifying how results must match the selected facet values.
Default:
atLeastOneValue -
sortCriteria?:
'ascending' | 'descending'The sort criterion to apply to the returned facet values.
Default:
ascending
Utils
buildNumericRange
Creates a NumericRangeRequest.
Parameters
-
config:
NumericRangeOptionsThe options with which to create a
NumericRangeRequest.
Returns NumericRangeRequest: The options defining a value to display in a NumericFacet.
Related types
NumericFacetValue
Properties
-
end:
numberThe ending value for the numeric range.
-
endInclusive:
booleanWhether or not the end value is included in the range.
-
numberOfResults:
numberThe number of results that have the facet value.
-
start:
numberThe starting value for the numeric range.
-
state:
'idle' | 'selected' | 'excluded'The state of the facet value, indicating whether it is filtering results (
selected) or not (idle).
NumericRangeOptions
Properties
-
end:
numberThe ending value of the numeric range.
-
start:
numberThe starting value of the numeric range.
-
endInclusive?:
booleanWhether to include the
endvalue in the range.Default:
false -
state?:
'idle' | 'selected' | 'excluded'The current facet value state.
Default:
idle
NumericRangeRequest
Properties
-
end:
numberThe end value of the range.
-
endInclusive:
booleanWhether to include the
endvalue in the range. -
start:
numberThe start value of the range.
-
state:
'idle' | 'selected' | 'excluded'The current facet value state.
Unsubscribe
Call signatures
-
(): void;