The Context controller injects custom contextual information into the search requests and usage analytics search events sent from a search interface.

Example: context.ts

interface Context {
    state: ContextState;
    add(contextKey: string, contextValue: ContextValue): void;
    remove(key: string): void;
    set(context: ContextPayload): void;
    subscribe(listener: () => void): Unsubscribe;
}

Hierarchy (View Summary)

Methods

Properties

Methods

  • Adds (or, if one is already present, replaces) a new context key-value pair.

    Parameters

    • contextKey: string

      The context key to add.

    • contextValue: ContextValue

      The context value to add.

    Returns void

  • Removes a context key from the query.

    Parameters

    • key: string

      The context key to remove.

    Returns void

  • Sets the context for the query. This replaces any existing context with the new one.

    Parameters

    Returns void

  • Adds a callback that's invoked on state change.

    Parameters

    • listener: () => void

      A callback that's invoked on state change.

    Returns Unsubscribe

    A function to remove the listener.

Properties

The state of the Context controller.