Support Menu

Coveo component Omnibox

Coveo Omnibox Component (CoveoOmnibox)

The Omnibox component is very similar to the simpler Querybox component. It supports all of the same options and behaviors.

The Omnibox component takes care of adding type-ahead capability to the search input. Custom components can extend and customize the type-ahead and the suggestions it provides.

The type-ahead is configurable by activating addons, which the Coveo JavaScript Search Framework provides OOTB (facets, analytics suggestions, Coveo Machine Learning suggestions and advanced Coveo syntax suggestions).

It is also possible for external code to provide type-ahead suggestions.

See also the Searchbox component, which can automatically instantiate an Omnibox component along with an optional SearchButton component.

Index

Component Options

enableFieldAddon

enableFieldAddon: boolean

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

The field addon allows the search box to highlight and complete field syntax.

Example:

Suppose you want to filter on a certain file type. You start typing @sysf in the input. The Omnibox provides you with several matching fields. You select the @sysfiletype suggestion and type =. If this option is set to true, then the Omnibox provides you with suggestions for available matching file types.

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

Specifies whether to enable the Coveo Machine Learning (Coveo ML) query suggestions.

This implies that you have a proper Coveo ML integration configured (see Managing Machine Learning Query Suggestions in a Query Pipeline).

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

Specifies whether to automatically trigger a new query whenever the end user types new text inside the Omnibox.

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

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 suggestions appearing in the Omnibox should push the result down instead of appearing over the results.

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 user types new text inside the Omnibox.

Default value is 2000. Minimum value is 0.

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

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

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

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