Changes the active path.
Return the debug info about this component.
Goes through any value that contains the value parameter, and verifies whether there are missing parents. Issues are then logged in the console. If you do not want to specify a value, you can simply enable CategoryFacet.options.debug and do an empty query.
Deselects the last value in the hierarchy that is applied to the query. When at the top of the hierarchy, this method does nothing.
Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Components are enabled by default on creation.
Enable the component. Normally this means that the component will execute handlers for the framework events (query events, for example). Components are enabled by default on creation.
Returns the values at the bottom of the hierarchy. These are the values that are not yet applied to the query.
simple object with three fields: value
, count
and path
.
Return the bindings, or environment, for the current component.
The string to find a caption for. Returns the caption for a value or the value itself if no caption is available.
Returns all the visible parent values.
simple object with three fields: value
, count
and path
.
Hides the component.
Reloads the facet with the same path.
Resets the facet to its initial state.
Selects a value from the currently available values. If the given value to select is not in the available values, it will throw an error.
Shows the component.
Shows less values, up to the original number of values.
See the enableMoreLess
, and
numberOfValues
options.
Shows more values according to CategoryFacet.options.pageSize.
See the enableMoreLess
, and
numberOfValues
options.
Get the bound component to the given HTMLElement. Throws an assert if the HTMLElement has no component bound, unless using the noThrow argument.
If there is multiple component bound to the current HTMLElement, you must specify the component class.
HTMLElement for which to get the bound component.
Optional component class. If the HTMLElement has multiple components bound, you must specify which one you are targeting.
Boolean option to tell the method to not throw on error.
Allows the component to bind events and execute them only when it is enabled.
Contains the state of options for different components. Mainly used by ResultLink.
Contains the state of different components (enabled vs disabled). Allows to get/set values. Triggers component state event when modified. Each component can listen to those events.
A disabled component will not participate in the query, or listen to ComponentEvents.
Allows component to log in the dev console.
Contains the singleton that allows to trigger queries.
Contains the state of the query. Allows to get/set values. Trigger query state event when modified. Each component can listen to those events.
A reference to the root HTMLElement (the SearchInterface).
A reference to the root of every component, the SearchInterface.
The static ID that each component needs in order to be identified.
For example, SearchButton -> static ID: SearchButton -> className: CoveoSearchButton
A reference to the Analytics.client.
The path to use as the path prefix for every query.
Example:
You have the following files indexed on a file system:
c:\
folder1\
text1.txt
folder2\
folder3\
text2.txt
Setting the basePath
to c
would display folder1
and folder2
in the CategoryFacet
, but omit c
.
This options accepts an array of values. To specify a "deeper" starting path in your tree, you need to use comma-separated values.
For example, setting data-base-path="c,folder1"
on the component markup would display folder3
in the CategoryFacet
, but omit c
and folder1
.
Whether to activate field format debugging. This options logs messages in the console for any potential encountered issues. This option can have negative effects on performance, and should only be activated when debugging.
data-debug='true' data-debug='false'
The character that specifies the hierarchical dependency.
Example:
If your field has the following values:
@field: c; c>folder2; c>folder2>folder3;
The delimiting character is >
.
Default value is |
.
data-delimiting-character='foo'
The id of another facet in which at least one value must be selected in order for the dependent category facet to be visible.
Default: undefined
and the category facet does not depend on any other facet to be displayed.
data-depends-on='foo'
A function that verifies whether the current state of the dependsOn
facet allows the dependent facet to be displayed.
If specified, the function receives a reference to the resolved dependsOn
facet component instance as an argument, and must return a boolean.
The function's argument should typically be treated as read-only.
By default, the dependent facet is displayed whenever one or more values are selected in its dependsOn
facet.
Whether to display the facet search widget as a button instead of a search bar.
data-display-search-button='true' data-display-search-button='false'
Whether to display the facet search widget above the facet values instead of below them.
data-display-search-on-top='true' data-display-search-on-top='false'
Whether to display a search box at the bottom of the facet for searching among the available facet
field
values.
See also the facetSearchDelay
, and
numberOfResultsInFacetSearch
options.
Default value is true
.
data-enable-facet-search='true' data-enable-facet-search='false'
Whether to enable the More and Less buttons in the Facet.
See also the pageSize
option.
Default value is true
.
data-enable-more-less='true' data-enable-more-less='false'
If the enableFacetSearch
option is true
, specifies the delay (in
milliseconds) before sending a search request to the server when the user starts typing in the category facet search box.
Specifying a smaller value makes results appear faster. However, chances of having to cancel many requests sent to the server increase as the user keeps on typing new characters.
Default value is 100
. Minimum value is 0
.
data-facet-search-delay='10'
The index field whose values the facet should use. The field values should have the form:
the; the|path; the|path|to; the|path|to|given; the|path|to|given|item;
where the delimiting character is |
. This default delimiting character can be changed using the delimitingCharacter option.
To help you verify whether your fields are setup correctly, see the CategoryFacet.options.debug option and the CategoryFacet.debugValue method.
data-field='@foo'
A unique identifier for the facet. Among other things, this identifier serves the purpose of saving the facet state in the URL hash.
If you have two facets with the same field on the same page, you should specify an id
value for at least one of
those two facets. This id
must be unique among the facets.
Default value is the field
option value.
data-id='foo'
The injection depth to use.
The injection depth determines how many results to scan in the index to ensure that the category facet lists all potential facet values. Increasing this value enhances the accuracy of the listed values at the cost of performance.
Default value is 1000
. Minimum value is 1000
.
data-injection-depth='1500'
The maximum number of levels to traverse in the hierarchy. This option does not count the length of the base path. The depth depends on what is shown in the interface.
Default value is Number.MAX_VALUE
.
data-maximum-depth='10'
If the enableFacetSearch
option is true
, specifies the number of
values to display in the facet search results popup.
Default value is 15
. Minimum value is 1
.
data-number-of-results-in-facet-search='10'
The maximum number of field values to display by default in the facet before the user clicks the arrow to show more.
See also the enableMoreLess
option.
data-number-of-values='10'
If the enableMoreLess
option is true
, specifies the number of
additional results to fetch when clicking the More button.
Default value is 10
. Minimum value is 1
.
data-page-size='10'
The title to display at the top of the facet.
Default value is the localized string for NoTitle
.
data-title='foo'
Specifies a JSON object describing a mapping of facet values to their desired captions. See Normalizing Facet Value Captions.
Note: If this option is specified, the facet search box will be unavailable.
Examples:
You can set the option in the 'init' call:
var myValueCaptions = {
"txt" : "Text files",
"html" : "Web page",
[ ... ]
};
Coveo.init(document.querySelector("#search"), {
Facet : {
valueCaption : myValueCaptions
}
});
Or before the init
call, using the 'options' top-level function:
Coveo.options(document.querySelector("#search"), {
Facet : {
valueCaption : myValueCaptions
}
});
Or directly in the markup:
<!-- Ensure that the double quotes are properly handled in data-value-caption. -->
<div class='CoveoCategoryFacet' data-field='@myotherfield' data-value-caption='{"txt":"Text files","html":"Web page"}'></div>
Create a new Component. Resolve all IComponentBindings if not provided.
Create a new Logger for this component.
Attach the component to the SearchInterface.
The HTMLElement on which to create the component. Used to bind data on the element.
The unique identifier for this component. See: IComponentDefinition.ID. Used to generate the unique Coveo CSS class associated with every component.
The environment for every component. Optional, but omitting to provide one will impact performance.
The
CategoryFacet
component is a facet that renders values in a hierarchical fashion. It determines the filter to apply depending on the current selected path of values.The path is a sequence of values that leads to a specific value in the hierarchy. It is an array listing all the parents of a file (e.g.,
['c', 'folder1']
for thec:\folder1\text1.txt
file).This facet requires a
field
with a special format to work correctly (see Using the Category Facet Component).Coveo for Salesforce Free
January 2019 Release (v2.5395.12)