@coveo/headless-react
    Preparing search index...

    Interface FieldSuggestions

    The FieldSuggestions controller provides query suggestions based on a particular facet field.

    For example, you could use this controller to provide auto-completion suggestions while the end user is typing an item title.

    This controller is a wrapper around the basic facet controller search functionality, and thus exposes similar options and properties.

    Example: field-suggestions.fn.tsx

    interface FieldSuggestions {
        state: FieldSuggestionsState;
        clear(): void;
        search(): void;
        select(value: FieldSuggestionsValue): void;
        showMoreResults(): void;
        singleSelect(value: FieldSuggestionsValue): void;
        subscribe(listener: () => void): Unsubscribe;
        updateCaptions(captions: Record<string, string>): void;
        updateText(text: string): void;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Resets the query and empties the suggestions.

      Returns void

    • Requests field suggestions based on a query.

      Returns void

    • Filters the search using the specified value.

      If a facet exists with the configured facetId, selects the corresponding facet value.

      Parameters

      Returns void

    • Shows more field suggestions for the current query.

      Returns void

    • Filters the search using the specified value, deselecting others.

      If a facet exists with the configured facetId, selects the corresponding facet value while deselecting other facet values.

      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.

    • Updates the captions of field suggestions.

      Parameters

      • captions: Record<string, string>

        A dictionary that maps field values to field suggestion display names.

      Returns void

    • Requests field suggestions based on a query.

      Parameters

      • text: string

        The query to search.

      Returns void

    Properties