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

    Interface CategoryFilterSuggestionsAlpha

    The CategoryFilterSuggestions controller provides methods to request and interact with category facet suggestions based on a specific field for a given search query.

    This controller relies on a Commerce API functionality that is not yet generally available. If you wish to use this feature in an implementation, please contact your Coveo representative.

    interface CategoryFilterSuggestions {
        state: CategoryFilterSuggestionsState;
        type: "hierarchical";
        clear(): void;
        getSearchParameters(value: CategoryFieldSuggestionsValue): string;
        select(value: CategoryFieldSuggestionsValue): void;
        subscribe(listener: () => void): Unsubscribe;
        updateQuery(query: string): void;
    }

    Hierarchy (View Summary)

    • Controller
    • FacetControllerType<"hierarchical">
      • CategoryFilterSuggestions
    Index

    Methods

    • Alpha

      Resets the query in the controller state and clears the category filter suggestions.

      Returns void

    • Alpha

      Returns the serialized search parameters for the current search query and specified category filter suggestion.

      For example, q=jeans&cf-ec-category=Clothes,Pants.

      In a typical scenario, this method should called when the user selects a category filter suggestion from a standalone search box. The returned string is then used to pass the correct URL query parameters or fragment when redirecting the browser to the search page.

      When the user selects a category filter suggestion from the main search box on the search page, use the select method instead.

      Parameters

      Returns string

      The serialized search parameters for the current search query and specified category filter suggestion.

    • Alpha

      Clears all facet values, selects the specified category filter suggestion, updates the query, and executes a new search request.

      In a typical scenario, this method should be called when the user selects a category filter suggestion from the main search box on the search page.

      When the user selects a category filter suggestion from a standalone search box, use the getSearchParameters method instead.

      Parameters

      Returns void

    • Alpha

      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.

    • Alpha

      Sets the query in the controller state to the specified value and requests category filter suggestions based on the updated query.

      For example, if this method is called with jeans as an argument, it will request values from the controller's field (e.g., ec_category) that would return results if selected when the search query is jeans (such as Clothing, Clothing;Pants, and Clothing;Shorts).

      Parameters

      • query: string

        The search query to use as context to request the category filter suggestions. In a typical scenario, this should set to the current value of the search box input.

      Returns void

    Properties

    type: "hierarchical"