Attaches a component to the search interface. This allows the search interface to easily list and iterate over its components.
Normally, the component type is a unique identifier without the Coveo
prefix (e.g., CoveoFacet
->
Facet
, CoveoPager
-> Pager
, CoveoQuerybox
-> Querybox
, etc.).
The component instance to attach.
Return the debug info about this component.
Detaches a component from the search interface.
Normally, the component type is a unique identifier without the Coveo
prefix (e.g., CoveoFacet
->
Facet
, CoveoPager
-> Pager
, CoveoQuerybox
-> Querybox
, etc.).
The component instance to detach.
Detaches from the SearchInterface every component that is inside the given element.
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 bindings, or environment, for the current component.
Gets all the components of a given type.
Normally, the component type is a unique identifier without the Coveo
prefix (e.g., CoveoFacet
->
Facet
, CoveoPager
-> Pager
, CoveoQuerybox
-> Querybox
, etc.).
Gets the query context for the current search interface.
If the search interface has performed at least one query, it will try to resolve the context from the last query sent to the Coveo Search API.
If the search interface has not performed a query yet, it will try to resolve the context from any avaiable PipelineContext component.
If multiple PipelineContext components are available, it will merge all context values together.
Note: Having multiple PipelineContext components in the same search interface is not recommended, especially if some context keys are repeated across those components.
If no context is found, returns undefined
A disabled component will not participate in the query, or listen to ComponentEvents.
Allows component to log in the dev console.
Allows to get and set the different breakpoints for mobile and tablet devices.
This is useful, amongst other, for Facet, Tab and ResultList
The static ID that each component needs in order to be identified.
For example, SearchButton -> static ID: SearchButton -> className: CoveoSearchButton
Specifies if the search interface should perform queries when no keywords are entered by the end user.
When this option is set to true, the interface will initially only load with the search box, as long as you have a search box component in your interface.
Once the user submits a query, the full search interface loads to display the results.
When using the Coveo for Salesforce Free edition, this option is automatically set to false, and should not be changed.
This option interacts closely with the SearchInterface.options.autoTriggerQuery option, as the automatic query is not triggered when there are no keywords.
It also modifies the IQuery.allowQueriesWithoutKeywords query parameter.
Default value is true
, except in Coveo for Salesforce Free edition in which it is false
.
data-allow-queries-without-keywords='true' data-allow-queries-without-keywords='false'
Specifies whether to trigger the first query automatically when the page finishes loading.
Default value is true
.
data-auto-trigger-query='true' data-auto-trigger-query='false'
Specifies whether to enable automatic responsive mode (i.e., automatically placing Facet and Tab components in dropdown menus under the search box when the width of the SearchInterface HTML element reaches or falls behind a certain pixel threshold).
You might want to set this option to false
if automatic responsive mode does not suit the specific design needs
of your implementation.
Note:
If this option is
true
, you can also specify whether to enable responsive mode for Facet components (see {@link Facet.options.enableResponsiveMode}) and for Tab components (see Tab.options.enableResponsiveMode).In addition, you can specify the label you wish to display on the dropdown buttons (see {@link Facet.options.dropdownHeaderLabel} and Tab.options.dropdownHeaderLabel).
Default value is true
.
data-enable-automatic-responsive-mode='true' data-enable-automatic-responsive-mode='false'
Note:
The Coveo Cloud V2 platform does not support collaborative rating. Therefore, this option is obsolete in Coveo Cloud V2.
Specifies whether to enable collaborative rating, which you can leverage using the
ResultRating
component.
Setting this option to true
has no effect unless collaborative rating is also enabled on your Coveo index.
Default value is false
.
data-enable-collaborative-rating='true' data-enable-collaborative-rating='false'
Specifies whether to enable the feature that allows the end user to ALT + double click any result to open a debug page with detailed information about all properties and fields for that result.
Enabling this feature causes no security concern; the entire debug information is always visible to the end user through the browser developer console or by calling the Coveo API directly.
Default value is true
.
data-enable-debug-info='true' data-enable-debug-info='false'
Whether to filter out duplicates, so that items resembling one another only appear once in the query results.
Notes:
Tab
component. When this is the case, the Tab
configuration prevails.data-enable-duplicate-filtering='true' data-enable-duplicate-filtering='false'
Whether to allow the end user to navigate search history using the Back and Forward buttons of the browser.
If this option is set to true
, the state of the current query will be saved in the hash portion
of the URL when the user submits the query.
Example:
If the
enableHistory
option istrue
and the current query isfoobar
, the SearchInterface component savesq=foobar
in the URL hash when the user submits the query.
Note: Avoid setting this option to true
on a search interface that relates to a Coveo for Salesforce Full Search or Insight Panel component, otherwise the component won't initialize correctly.
data-enable-history='true' data-enable-history='false'
Specifies whether to restore the last scroll position when navigating back to the search interface.
data-enable-scroll-restoration='true' data-enable-scroll-restoration='false'
Specifies the number of characters to get at query time to create an excerpt of the result.
This setting is global and cannot be modified on a per-result basis.
See also the Excerpt component.
Default value is 200
. Minimum value is 0
.
data-excerpt-length='10'
Specifies an expression to add to each query.
You might want to use this options to add a global filter to your entire search interface that applies for all tabs.
You should not use this option to address security concerns (it is JavaScript, after all).
Note:
It also is possible to set this option separately for each Tab component (see Tab.options.expression).
Default value is ''
.
data-expression='foo'
Specifies the name of a field to use as a custom filter when executing the query (also referred to as "folding").
Setting a value for this option causes the index to return only one result having any particular value inside the filter field. Any other matching result is "folded" inside the childResults member of each JSON query result.
This feature is typically useful with threaded conversations to include only one top-level result per conversation. Thus, the field you specify for this option will typically be value unique to each thread that is shared by all items (e.g., posts, emails, etc) in the thread.
For more advanced features, see the Folding component.
Default value is the empty string (''
).
data-filter-field='@foo'
Specifies the animation that you wish to display while your interface is loading.
You can either specify the CSS selector of an HTML element that matches the default CSS class
(coveo-first-loading-animation
), or add -selector
to the markup attribute of this option to specify the CSS
selector of an HTML element that matches any CSS class.
See also the hideUntilFirstQuery option.
Examples:
In this first case, the SearchInterface uses the HTML element whose id
attribute is MyAnimation
as the
loading animation only if the class
attribute of this element also matches coveo-first-loading-animation
.
Default loading animation CSS, which you can customize as you see fit, applies to this HTML element.
<div class='CoveoSearchInterface' data-first-loading-animation='#MyAnimation'>
<div id='MyAnimation' class='coveo-first-loading-animation'>
<!-- ... -->
</div>
<!-- ... -->
</div>
In this second case, the SearchInterface uses the HTML element whose id
attribute is MyAnimation
as the
loading animation no matter what CSS class it matches. However, if the class
attribute of the HTML element does
not match coveo-first-loading-animation
, no default loading animation CSS applies to this HTML element.
Normally, you should only use data-first-loading-animation-selector
if you want to completely override the
default loading animation CSS.
<div class='CoveoSearchInterface' data-first-loading-animation-selector='#MyAnimation'>
<div id='MyAnimation' class='my-custom-loading-animation-class'>
<!-- ... -->
</div>
<!-- ... -->
</div>
By default, the loading animation is a Coveo CSS animation (which you can customize with CSS).
Specifies whether to display a loading animation before the first query successfully returns.
Note:
If you do not set this options to
false
, the loading animation will still run until the first query successfully returns even if the autoTriggerQuery option isfalse
.
See also the firstLoadingAnimation option.
Default value is true
.
data-hide-until-first-query='true' data-hide-until-first-query='false'
Specifies the maximum age (in milliseconds) that cached query results can have to still be usable as results instead of performing a new query on the index. The cache is located in the Coveo Search API (which resides between the index and the search interface).
If cached results that are older than the age you specify in this option are available, the framework will not use these results; it will rather perform a new query on the index.
On high-volume public web sites, specifying a higher value for this option can greatly improve query response time at the cost of result freshness.
Note:
It also is possible to set this option separately for each Tab component (see Tab.options.maximumAge).
Default value is undefined
, which means that the search interface lets the Coveo Search API determine the
maximum cache age. This is typically equivalent to 30 minutes (see
maximumAge).
data-maximum-age='10'
Specifies the HTMLElement to which Modals components of the search interface will be attached to. You can either specify a CSS selector or pass an HTMLElement in the options when calling Coveo.init.
Default value is element.ownerDocument.body
.
Example in attribute:
<div class="CoveoSearchInterface" data-modal-container="#my-modal-container"></div>
Example in init options:
var myContainer = document.getElementById('my-modal-container');
Coveo.init(root, {
SearchInterface: {
modalContainer: myContainer
}
});
Specifies the name of the query pipeline to use for the queries.
You can specify a value for this option if your index is in a Coveo Cloud organization in which pipelines have been created (see Adding and Managing Query Pipelines).
Note:
It also is possible to set this option separately for each Tab component (see Tab.options.pipeline).
Default value is undefined
, which means that the search interface uses the default pipeline.
data-pipeline='foo'
Specifies the search interface width that should be considered "medium" size, in pixels.
When the width of the window/device that displays the search page reaches or falls short of this threshold (but still exceeds the responsiveSmallBreakpoint value), the search page layout will change so that, for instance, facets within the element that has the coveo-facet-column class will be accessible from a dropdown menu on top of the result list rather than being fully rendered next to the result list.
This option is only taken into account when enableAutomaticResponsiveMode is set to true.
Default value is 800
.
data-responsive-medium-breakpoint='10'
Specifies the search interface responsive mode that should be used.
When the mode is auto, the width of the window/device that displays the search page is used to determine which layout the search page should use (see enableAutomaticResponsiveMode, responsiveMediumBreakpoint and [responsiveSmallBreakpointSearchInterface.options.responsiveSmallBreakpoint])
When it's not on auto, the width is ignored and the the layout used depends on this option (e.g. If set to "small", then the search interface layout will be the same as if it was on a narrow window/device)
Specifies the search interface width that should be considered "small" size, in pixels.
When the width of the window/device that displays the search page reaches or falls short of this threshold, the search page layout will change so that, for instance, some result list layouts which are not suited for being rendered on a small screen/area will be disabled.
This option is only taken into account when enableAutomaticResponsiveMode is set to true.
Default value is 480
.
data-responsive-small-breakpoint='10'
Specifies the number of results to display on each page.
For more advanced features, see the ResultsPerPage component.
Note:
When the ResultsPerPage component is present in the page, this option gets overridden and is useless.
Default value is 10
. Minimum value is 0
.
data-results-per-page='10'
Specifies the search page you wish to navigate to when instantiating a standalone search box interface.
Default value is undefined
, which means that the search interface does not redirect.
data-search-page-uri='foo'
Specifies the timezone in which the search interface is loaded. This allows the index to recognize some special query syntax.
This option must have a valid IANA zone info key (AKA the Olson time zone database) as its value.
Example: America/New_York
.
By default, the search interface allows a library to try to detect the timezone automatically.
data-timezone='foo'
Specifies whether to save the interface state in the local storage of the browser.
You might want to set this option to true
for reasons specifically important for your implementation.
Default value is false
.
data-use-local-storage-for-history='true' data-use-local-storage-for-history='false'
Creates a new SearchInterface. Initialize various singletons for the interface (e.g., usage analytics, query controller, state model, etc.). Binds events related to the query.
The HTMLElement on which to instantiate the component. This cannot be an HTMLInputElement
for
technical reasons.
The options for the SearchInterface.
The options for the Analytics component. Since the Analytics component is normally global, it needs to be passed at initialization of the whole interface.
The window object for the search interface. Used for unit tests, which can pass a mock. Default is the global window object.
The SearchInterface component is the root and main component of your Coveo search interface. You should place all other Coveo components inside the SearchInterface component.
It is also on the HTMLElement of the SearchInterface component that you call the init function.
It is advisable to specify a unique HTML
id
attribute for the SearchInterface component in order to be able to reference it easily.Example:
<head> [ ... ] <script> document.addEventListener('DOMContentLoaded', function() { [ ... ] // The init function is called on the SearchInterface element, in this case, the body of the page. Coveo.init(document.body); [ ... ] }); </script> [ ... ] </head> <!-- Specifying a unique HTML id attribute for the SearchInterface component is good practice. --> <body id='search' class='CoveoSearchInterface' [ ... other options ... ]> [ ... ] <!-- You should place all other Coveo components here, inside the SearchInterface component. --> [ ... ] </body>