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

See also the 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). Components 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 different components. Mainly used by ResultLink.

componentStateModel

componentStateModel: ComponentStateModel

Contains the state of different components (enabled vs disabled). Allows to get/set values. Triggers 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.

Static ID

ID: string

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

Accessors

usageAnalytics

Component Options

clearFiltersOnNewQuery

clearFiltersOnNewQuery: boolean

Whether to clear all active query filters when the end user submits a new query from the search box.

Note: This does not include the filter expression enforced by the currently selected tab, if any.

Default

false

Available since

September 2019 Release (v2.7023)

Markup configuration example(s) :
data-clear-filters-on-new-query='true'
data-clear-filters-on-new-query='false'

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.

Only effective when

enableQuerySyntax is truthy

Default

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.

Only effective when

enableQuerySyntax is truthy

Default

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.

A Coveo ML query suggestions (QS) model must be properly configured in your Coveo Cloud organization, otherwise this option has no effect (see Create a QS Model).

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

true

Available since

December 2015 Release (v1.0.273)

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.

Default

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.

Default

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.

Default

false

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

numberOfSuggestions

numberOfSuggestions: number

Specifies the number of suggestions that should appear in standard ML-powered query suggestions.

This option only affects the number of suggestions that appear with the Omnibox.options.enableQuerySuggestAddon option.

This options does not affect the AnalyticsSuggestions or the FieldSuggestions component, which expose their own dedicated options for this parameter.

Default value is 5.

Minimum value is 1.

Minimum

1

Default

5

Markup configuration example(s) :
data-number-of-suggestions='10'

omniboxTimeout

omniboxTimeout: number

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

Default value is 2000. Minimum value is 0.

Minimum

0

Default

2000

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

placeholder

placeholder: string

Specifies a placeholder for the input.

Available since

July 2016 Release (v1.667.24)

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

querySuggestCharacterThreshold

querySuggestCharacterThreshold: number

The minimum number of characters required in the in the text input before displaying available query suggestions when focus is on the component.

Note: Only effective when enableQuerySuggestAddon is true.

depend: 'enableQuerySuggestAddon'

Default (and minimum): 0, meaning that trending query suggestions are displayed when focus is on the component, even if its text input is empty.

Minimum

0

Default

0

Available since

July 2019 Release (v2.6459)

Markup configuration example(s) :
data-query-suggest-character-threshold='10'

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.

Only effective when

enableSearchAsYouType is truthy

Minimum

0

Default

2000

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