Support Menu

Coveo JavaScript Search Framework - Reference Documentation

Index

Coveo components

Modules

Classes

Interfaces

Type aliases

Functions

Type aliases

BaseFormTypes

The basic types of form available to build an advanced search section.

ValidLayout

ValidLayout: "list" | "card" | "table"

The possible valid and supported layouts.

See the Result Layouts documentation.

Functions

$$

executeQuery

  • executeQuery(element: HTMLElement): Promise
  • Execute a standard query. Active component in the interface will react to events/ push data in the query / handle the query success or failure as needed.
    It triggers a standard query flow for which the standard component will perform their expected behavior.
    If you wish to only perform a query on the index to retrieve results (without the component reacting), look into SearchInterface instead.
    Calling this method is the same as calling QueryController.executeQuery.

    Parameters

    • element: HTMLElement

      The root of the interface to initialize.

    Returns Promise

get

  • get(element: HTMLElement, componentClass?: any, noThrow?: boolean): BaseComponent
  • Get the component bound on the given HTMLElement.

    Parameters

    • element: HTMLElement

      The HTMLElement for which to get the component instance.

    • Optional componentClass: any

      If multiple components are bound to a single HTMLElement, you need to specify which components you wish to get.

    • Optional noThrow: boolean

      By default, the GET method will throw if there is no component bound, or if there are multiple component and no componentClass is specified. This deletes the error if set to true.

    Returns BaseComponent

init

  • init(element: HTMLElement, options?: any): void
  • Initialize the framework with a basic search interface. Calls Initialization.initSearchInterface.
    If using the jQuery extension, this is called using $('#root').coveo('init');.

    Parameters

    • element: HTMLElement

      The root of the interface to initialize.

    • Default value options: any = {}

      JSON options for the framework (e.g.: {Searchbox : {enableSearchAsYouType : true}}).

    Returns void

initRecommendation

  • initRecommendation(element: HTMLElement, mainSearchInterface?: HTMLElement, userContext?: object, options?: any): void
  • Initialize the framework with a recommendation interface. Calls Initialization.initRecommendationInterface.
    If using the jQuery extension, this is called using $('#root').coveo('initRecommendation');.

    Parameters

    • element: HTMLElement

      The root of the interface to initialize.

    • Optional mainSearchInterface: HTMLElement

      The search interface to link with the recommendation interface (see Recommendation).

    • Optional userContext: object

      The user context to pass with the query generated in the recommendation interface (see Recommendation).

      • [name: string]: any
    • Default value options: any = {}

      JSON options for the framework (e.g.: {Searchbox : {enableSearchAsYouType: true}}).

    Returns void

initSearchbox

  • initSearchbox(element: HTMLElement, searchPageUri: string, options?: any): void
  • Initialize the framework with a standalone search box. Calls {@link Initialize.initStandaloneSearchInterface}.
    If using the jQuery extension, this is called using $('#root').coveo('initSearchbox');.

    Parameters

    • element: HTMLElement

      The root of the interface to initialize.

    • searchPageUri: string

      The search page on which to redirect when there is a query.

    • Default value options: any = {}

      JSON options for the framework (e.g.: {Searchbox : {enableSearchAsYouType : true}}).

    Returns void

logClickEvent

logCustomEvent

  • Log a custom event on the Coveo Usage Analytics service.

    Parameters

    • element: HTMLElement

      The root of the interface for which to log analytics events.

    • customEventCause: IAnalyticsActionCause

      The cause of the event.

    • metadata: IStringMap<string>

      The metadata associated with the event (JSON key value).

    Returns void

logSearchAsYouTypeEvent

  • Log a SearchAsYouTypeEvent on the Coveo Usage Analytics service.
    It is a bit different from a standard search event, as it will wait 5 seconds before sending the final SearchAsYouType event.

    Parameters

    • element: HTMLElement

      The root of the interface for which to log analytics events.

    • searchAsYouTypeEventCause: IAnalyticsActionCause

      The cause of the event.

    • metadata: IStringMap<string>

      The metadata associated with the event (JSON key value).

    Returns void

logSearchEvent

  • Log a SearchEvent on the Coveo Usage Analytics service.

    Parameters

    • element: HTMLElement

      The root of the interface for which to log analytics events.

    • searchEventCause: IAnalyticsActionCause

      The cause of the event.

    • metadata: IStringMap<string>

      The metadata associated with the event (JSON key value).

    Returns void

options

  • options(element: HTMLElement, optionsToSet?: any): void
  • Pass options to the framework, before it is initialized (init).
    All the options passed with this calls will be merged together on initialization.

    Parameters

    • element: HTMLElement

      The root of the interface for which you wish to set options.

    • Default value optionsToSet: any = {}

      JSON options for the framework (e.g.: {Searchbox : {enableSearchAsYouType: true}}).

    Returns void

patch

  • patch(element: HTMLElement, methodName: string, handler: function): void
  • Patch the given methodName on an instance of a component bound to an HTMLElement with a new handler.

    Parameters

    • element: HTMLElement
    • methodName: string
    • handler: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

polyfill

  • polyfill(): void

state

  • state(element: HTMLElement, ...args: any[]): any
  • Perform operation on the state (QueryStateModel of the interface.
    Get the complete QueryStateModel object: Coveo.state(element)
    . Get an attribute from the QueryStateModel: Coveo.state(element, 'q') Can be any attribute.
    Set an attribute on the QueryStateModel: Coveo.state(element, 'q', 'foobar'). Can be any attribute.
    Set multiple attribute on the QueryStateModel: Coveo.state(element, {'q' : 'foobar' , sort : 'relevancy'}). Can be any attribute.
    If using the jQuery extension, this is called using $('#root').coveo('state');.

    Parameters

    • element: HTMLElement

      The root of the interface for which to access the QueryStateModel.

    • Rest ...args: any[]

    Returns any