Support Menu

Coveo component Omnibox

Coveo Omnibox Component (CoveoOmnibox)

The Omnibox component extends the Querybox, and thus provides the same basic options and behaviors. Furthermore, the Omnibox adds a type-ahead capability to the search input.

You can configure the type-ahead feature by enabling or disabling certain addons, which the Coveo JavaScript Search Framework provides out-of-the-box (see the enableFieldAddon, enableQueryExtension, and enableQuerySuggestAddon options).

Custom components and external code can also extend or customize the type-ahead feature and the query completion suggestions it provides by attaching their own handlers to the [populateOmniboxSuggestions]{@link OmniboxEvents.populateOmniboxSuggestions`] event.

See also the [Searchbox]{@link Searchbox} component, which can automatically instantiate an Omnibox along with an optional SearchButton.

Index

Methods

clear

  • clear(): void

debugInfo

  • debugInfo(): any

disable

  • disable(): void
  • Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Component are enabled by default on creation.

    Returns void

enable

  • enable(): void
  • 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 void

getBindings

getInput

  • getInput(): HTMLInputElement

getText

  • getText(): string

setText

  • setText(text: string): void
  • Sets the content of the input

    Parameters

    • text: string

      The string to set in the input.

    Returns void

submit

  • submit(): void
  • Adds the current content of the input to the query and triggers a query if the current content of the input has changed since last submit.

    Also logs a searchboxSubmit event in the usage analytics.

    Returns void

Static get

  • get(element: HTMLElement, componentClass?: any, noThrow?: boolean): BaseComponent
  • 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.

    Parameters

    • element: HTMLElement

      HTMLElement for which to get the bound component.

    • Optional componentClass: any

      Optional component class. If the HTMLElement has multiple components bound, you must specify which one you are targeting.

    • Optional noThrow: boolean

      Boolean option to tell the method to not throw on error.

    Returns BaseComponent

Properties

bind

Allows the component to bind events and execute them only when it is enabled.

type

{Coveo.ComponentEvents}

componentOptionsModel

componentOptionsModel: ComponentOptionsModel

Contains the state of options for differents component. Mainly used by ResultLink.

componentStateModel

componentStateModel: ComponentStateModel

Contains the state of different component (enabled vs disabled). Allows to get/set values. Trigger component state event when modified. Each component can listen to those events.

disabled

disabled: boolean

A disabled component will not participate in the query, or listen to ComponentEvents.

type

{boolean}

logger

logger: Logger

Allows component to log in the dev console.

queryController

queryController: QueryController

Contains the singleton that allows to trigger queries.

queryStateModel

queryStateModel: QueryStateModel

Contains the state of the query. Allows to get/set values. Trigger query state event when modified. Each component can listen to those events.

root

root: HTMLElement

A reference to the root HTMLElement (the SearchInterface).

searchInterface

searchInterface: SearchInterface

A reference to the root of every component, the SearchInterface.

usageAnalytics

usageAnalytics: IAnalyticsClient

A reference to the Analytics.client.

Static ID

ID: string

The static ID that each component need to be identified.
For example, SearchButton -> static ID : SearchButton -> className : CoveoSearchButton

Component Options

enableFieldAddon

enableFieldAddon: boolean

The field addon makes the Omnibox highlight and complete field syntax. Setting this option to true automatically sets the enableQuerySyntax option to true as a side effect.

Example:

Suppose you want to search for PDF files. You start typing @f in the search box. The Omnibox provides you with several matching fields. You select the @filetype field. Then, you start typing =p in the input. This time, the Omnibox provides you with several matching values for the @filetype field. You select the pdf suggestion, and submit your search request. Since the enableQuerySyntax option is set to true, the Coveo Search API interprets the basic expression as query syntax and returns the items whose @filetype field matches the pdf value.

Default value is false.

Markup configuration example(s) :
data-enable-field-addon='true'
data-enable-field-addon='false'

enableQueryExtensionAddon

enableQueryExtensionAddon: boolean

If Querybox.options.enableQuerySyntax is true, specifies whether to enable the query extension addon.

The query extension addon allows the Omnibox to complete the syntax for query extensions.

Default value is false.

Markup configuration example(s) :
data-enable-query-extension-addon='true'
data-enable-query-extension-addon='false'

enableQuerySuggestAddon

enableQuerySuggestAddon: boolean

Whether to display Coveo Machine Learning (Coveo ML) query suggestions in the Omnibox.

The corresponding Coveo ML model must be properly configured in your Coveo Cloud organization, otherwise this option has no effect (see Managing Machine Learning Query Suggestions in a Query Pipeline).

Note:

When you set this option and the enableSearchAsYouType option to true, the query suggestion feature returns the auto-completion of the currently typed keyword as its first query suggestion.

Default value is true.

Markup configuration example(s) :
data-enable-query-suggest-addon='true'
data-enable-query-suggest-addon='false'

enableQuerySyntax

enableQuerySyntax: boolean

Specifies whether the Coveo Platform should try to interpret special query syntax such as field references in the query that the user enters in the Querybox (see Coveo Query Syntax Reference).

Setting this option to true also causes the query syntax in the Querybox to highlight.

Default value is false.

Markup configuration example(s) :
data-enable-query-syntax='true'
data-enable-query-syntax='false'

enableSearchAsYouType

enableSearchAsYouType: boolean

Whether to automatically trigger a new query whenever the end user types additional text in the search box input.

See also the searchAsYouTypeDelay option.

Note:

If you set this option and the enableQuerySuggestAddon option to true, the query suggestion feature returns the auto-completion of the currently typed keyword as its first suggestion.

Default value is false.

Markup configuration example(s) :
data-enable-search-as-you-type='true'
data-enable-search-as-you-type='false'

inline

inline: boolean

Specifies whether query completion suggestions appearing in the Omnibox should push the result list and facets down, rather than rendering themselves over them (and partially hiding them).

Set this option as well as Omnibox.options.enableSearchAsYouType and Omnibox.options.enableQuerySuggestAddon to true for a cool effect!

Default value is false.

Markup configuration example(s) :
data-inline='true'
data-inline='false'

omniboxTimeout

omniboxTimeout: number

Specifies a timeout (in milliseconds) before rejecting suggestions in the Omnibox.

Default value is 2000. Minimum value is 0.

Markup configuration example(s) :
data-omnibox-timeout='10'

placeholder

placeholder: string

Specifies a placeholder for the input.

Markup configuration example(s) :
data-placeholder='foo'

searchAsYouTypeDelay

searchAsYouTypeDelay: number

If Omnibox.options.enableSearchAsYouType is true, specifies the delay (in milliseconds) before triggering a new query when the end user types in the Omnibox.

Default value is 2000. Minimum value is 0.

Markup configuration example(s) :
data-search-as-you-type-delay='10'

Constructors

constructor

  • Creates a new Omnibox component. Also enables necessary addons and binds events on various query events.

    Parameters

    • element: HTMLElement

      The HTMLElement on which to instantiate the component.

    • Optional options: IOmniboxOptions

      The options for the Omnibox component.

    • Optional bindings: IComponentBindings

      The bindings that the component requires to function normally. If not set, these will be automatically resolved (with a slower execution time).

    Returns Omnibox