Recommendation engine

This is for:

Developer

The engine for powering recommendation experiences.

Initialize

buildRecommendationEngine

Creates a recommendation engine instance.

Parameters

Returns RecommendationEngine

RecommendationEngineOptions

The recommendation engine options.

Properties

  • configuration: RecommendationEngineConfiguration

    The recommendation engine configuration options.

  • loggerOptions?: LoggerOptions

    The 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?: NavigatorContextProvider

    An optional function returning navigation context. (referer, location, UserAgent)

  • preloadedState?: State

    The 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.

RecommendationEngineConfiguration

The recommendation engine configuration options.

Properties

  • locale?: string

    The 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?: string

    Specifies the name of the query pipeline to use for the query. If not specified, the default query pipeline will be used.

  • preprocessSearchResponseMiddleware?: PostprocessSearchResponseMiddleware

    Allows for augmenting a search response before the state is updated.

  • proxyBaseUrl?: string

    The base URL to use to proxy Coveo search requests (e.g., https://example.com/search).

    This is an advanced option that you should only set if you need to proxy Coveo search requests through your own server. In most cases, you should not set this option.

    By default, no proxy is used and the Coveo Search API requests are sent directly to the Coveo platform through the search organization endpoint resolved from the organizationId and environment values provided in your engine configuration (i.e., https://<organizationId>.org.coveo.com or https://<organizationId>.org<environment>.coveo.com, if the environment values is specified and different from prod).

    If you set this option, you must also implement the following proxy endpoints on your server, otherwise the recommendation engine will not work properly:

  • searchHub?: string

    The 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?: string

    The 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.

  • accessToken: string

    The access token to use to authenticate requests against the Coveo Cloud 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 Cloud organization.

  • organizationId: string

    The unique identifier of the target Coveo Cloud organization (e.g., mycoveocloudorganizationg8tp8wu3)

  • analytics?: AnalyticsConfiguration

    Allows configuring options related to analytics.

  • environment?: PlatformCombination['env']

    The environment in which the organization is hosted.

    The dev and stg environments are only available internally for Coveo employees (e.g., Professional Services).

    Defaults to prod.

  • name?: string

    The Engine name (e.g., myEngine). Specifying your Engine name will help in debugging when using an application with multiple Redux stores.

    Default: 'coveo-headless'

  • preprocessRequest?: PreprocessRequest

    Allows 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

  • level?: LevelWithSilent

    By 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;

AnalyticsConfiguration

Allows configuring options related to analytics.

Properties

Unsubscribe

Call signatures

  • (): void;

Methods

addReducers

Adds the specified reducers to the store.

Parameters

  • reducers: ReducersMapObject

    An 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: () => void

    A callback to be invoked on every dispatch.

Returns Unsubscribe: A function to remove this change listener.