Search engine
Search engine
|
|
Note
This component was introduced in version |
The engine for powering search experiences.
Initialize
buildSearchEngine
Creates a search engine instance.
Parameters
-
options:
SearchEngineOptionsThe search engine options.
Returns SearchEngine
SearchEngineOptions
The search engine options.
Properties
-
configuration:
SearchEngineConfigurationThe search engine configuration options.
-
loggerOptions?:
LoggerOptionsThe logger options.
-
middlewares?:
Middleware<{}, State>[]List of additional middlewares. A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It is useful for logging actions, performing side effects like routing, or turning an asynchronous API call into a series of synchronous actions.
-
navigatorContextProvider?:
NavigatorContextProviderAn optional function returning navigation context. (referer, location, UserAgent)
-
preloadedState?:
StateThe initial headless state. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session.
SearchEngineConfiguration
The search engine configuration options.
Properties
-
search?:
SearchConfigurationOptionsThe global headless engine configuration options specific to the SearchAPI.
-
accessToken:
stringThe access token to use to authenticate requests against the Coveo endpoints. Typically, this will be an API key or search token that grants the privileges to execute queries and push usage analytics data in the target Coveo organization.
-
organizationId:
stringThe unique identifier of the target Coveo organization (for example,
mycoveocloudorganizationg8tp8wu3) -
analytics?:
AnalyticsConfigurationAllows configuring options related to analytics.
-
name?:
stringThe Engine name (for example, myEngine). Specifying your Engine name will help in debugging when using an application with multiple Redux stores.
Default: 'coveo-headless'
-
organizationEndpoints?:
OrganizationEndpointsThe endpoints to use.
For example:
https://orgid.org.coveo.comThe getOrganizationEndpoints helper function can be useful to create the appropriate object.
We recommend using this option, since it has resiliency benefits and simplifies the overall configuration for multi-region deployments. See Organization endpoints.
-
platformUrl?:
stringThe Platform URL to use. (for example, https://platform.cloud.coveo.com) The platformUrl() helper method can be useful to know what url is available.
-
preprocessRequest?:
PreprocessRequestAllows for augmenting a Platform request before it is sent.
-
renewAccessToken?:
() => Promise<string>A function that fetches a new access token. The function must return a Promise that resolves to a string (the new access token).
LoggerOptions
The logger options.
Properties
-
browserPostLogHook?:
(level: LogLevel, logEvent: LogEvent) => voidFunction which will be called after writing the log message in the browser.
-
level?:
LevelWithSilentBy default, is set to
warn. -
logFormatter?:
(object: {}) => {}Changes the shape of the log object. This function will be called every time one of the log methods (such as
.info) is called. All arguments passed to the log method, except the message, will be pass to this function. By default it does not change the shape of the log object.
Middleware<{}, State>[]
List of additional middlewares. A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It is useful for logging actions, performing side effects like routing, or turning an asynchronous API call into a series of synchronous actions.
Properties
-
(call):
(api: MiddlewareAPI<D, S>): (next: (action: unknown) => unknown) => (action: unknown) => unknown;
SearchConfigurationOptions
The global headless engine configuration options specific to the SearchAPI.
Properties
-
authenticationProviders?:
string[]Specifies the name of the authentication providers to use to perform queries.
See SAML Authentication.
-
locale?:
stringThe locale of the current user. Must comply with IETF’s BCP 47 definition: https://www.rfc-editor.org/rfc/bcp/bcp47.txt.
Notes: Coveo Machine Learning models use this information to provide contextually relevant output. Moreover, this information can be referred to in query expressions and QPL statements by using the $locale object.
-
pipeline?:
stringSpecifies the name of the query pipeline to use for the query. If not specified, the default query pipeline will be used.
-
preprocessFacetSearchResponseMiddleware?:
PostprocessFacetSearchResponseMiddlewareAllows for augmenting a facet-search response before the state is updated.
-
preprocessQuerySuggestResponseMiddleware?:
PostprocessQuerySuggestResponseMiddlewareAllows for augmenting a query-suggest response before the state is updated.
-
preprocessSearchResponseMiddleware?:
PostprocessSearchResponseMiddlewareAllows for augmenting a search response before the state is updated.
-
searchHub?:
stringThe first level of origin of the request, typically the identifier of the graphical search interface from which the request originates. Coveo Machine Learning models use this information to provide contextually relevant output. Notes: This parameter will be overridden if the search request is authenticated by a search token that enforces a specific searchHub. When logging a Search usage analytics event for a query, the originLevel1 field of that event should be set to the value of the searchHub search request parameter.
-
timezone?:
stringThe tz database identifier of the time zone to use to correctly interpret dates in the query expression, facets, and result items. By default, the timezone will be guessed.
AnalyticsConfiguration
Allows configuring options related to analytics.
Properties
-
analyticsClientMiddleware?:
AnalyticsClientSendEventHookanalyticsClientMiddleware allows to hook into an analytics event payload before it is sent to the Coveo platform.
-
analyticsMode?:
'legacy' | 'next'The analytics client to use. -
legacy: The legacy analytics client, that is, the Coveo Analytics.js library. -next: The next analytics client, that is, the Coveo Event Protocol with the Relay library. -
anonymous?:
booleanWhether analytics events should be logged anonymously. If set to true, the Usage Analytics Write API will not extract the name and userDisplayName, if present, from the search token
-
deviceId?:
stringThe name of the device that the end user is using. It should be explicitly configured in the context of a native mobile app.
-
documentLocation?:
stringSpecifies the URL of the current page or component.
-
enabled?:
booleanSpecifies if usage analytics tracking should be enabled.
By default, all analytics events will be logged.
-
originContext?:
stringSets the Origin Context dimension on the analytics events.
You can use this dimension to specify the context of your application. The possible values are "Search", "InternalSearch", and "CommunitySearch."
The default value is
Search. -
originLevel2?:
stringSets the value of the Origin Level 2 dimension on the analytics events.
Origin level 2 is a usage analytics event metadata whose value should typically be the name/identifier of the tab from which the usage analytics event originates.
In the context of product listing, the value should match the breadcrumb of the product listing page from which the usage analytics event originates (for example,
canoes-kayaks/kayaks/sea-kayaks).When logging a usage analytics event, originLevel2 should always be set to the same value as the corresponding
tab(parameter) Search API query parameter so Coveo Machine Learning models function properly, and usage analytics reports and dashboards are coherent.If left unspecified, this value will automatically try to resolve itself from the
tabSearch API query parameter. -
originLevel3?:
stringOrigin level 3 is a usage analytics event metadata whose value should typically be the URL of the page that linked to the search interface that’s making the request.
When logging a Search usage analytics event, originLevel3 should always be set to the same value as the corresponding referrer Search API query parameter so usage analytics reports and dashboards are coherent.
This value is optional, and will automatically try to resolve itself from the referrer search parameter.
-
runtimeEnvironment?:
IRuntimeEnvironmentOptional analytics runtime environment, this is needed for analytics to work correctly if you’re running outside of a browser. See https://github.com/coveo/coveo.analytics.js for more info.
-
trackingId?:
stringThe unique identifier of the tracking target.
-
userDisplayName?:
stringSpecifies the user display name for the usage analytics logs.
Related types
Unsubscribe
Call signatures
-
(): void;
Methods
executeFirstSearch
Executes the first search.
Parameters
-
analyticsEvent:
LegacySearchActionThe analytics event to log in association with the first search. If unspecified,
logInterfaceLoadwill be used.
executeFirstSearchAfterStandaloneSearchBoxRedirect
Executes the first search, and logs the analytics event that triggered a redirection from a standalone search box.
Parameters
-
analytics:
InitialData | SearchFromLinkData | OmniboxFromLinkDataThe standalone search box analytics data.
addReducers
Adds the specified reducers to the store.
Parameters
-
reducers:
ReducersMapObjectAn object containing the reducers to attach to the engine.
disableAnalytics
Disable analytics tracking
enableAnalytics
Enable analytics tracking
subscribe
Adds a change listener. It will be called any time an action is dispatched, and some part of the state tree may potentially have changed. You may then access the new state.
Parameters
-
listener:
() => voidA callback to be invoked on every dispatch.
Returns Unsubscribe: A function to remove this change listener.