Limiting the Number of Available or Allowed Values in Coveo Atomic Facet Filters
In this blog post we are discussing how to enhance the user experience and streamline Coveo atomic search filtering, by limiting the facet list to a predefined set of values, ensuring only relevant options are displayed. Additionally, removing the search box from the filter helps maintain a cleaner UI, preventing users from searching within the facet if it is a smaller set. These optimizations improve usability and provide a more controlled filtering experience.
Coveo Atomic Search
Coveo Atomic is a web component library designed for building responsive, accessible, and future-proof search interfaces powered by Coveo. These components are self-contained, modular, and lightweight. Internally, Atomic leverages the Coveo Headless library to interact with the Coveo Platform and manage the search application state.
A facet is a collection of values for a specific field found in the search results, organized based on configurable criteria (e.g., frequency of occurrence). The atomic-facet
component presents a facet of the results for the current query.
In the below screenshot, the Object type field has values such as Case, User, Task, Contact, etc.
Limiting the Facet List to a Set of Values
We can limit the list of facet values to a desired set of values by setting the allowedValues property. It should have either of the below formats.
<AtomicFacet allowedValues={'["Case","User","Task"]'} />
<atomic-facet allowed-values='["Case","User","Task"]'></atomic-facet>
With these, the filters will now only show Case, User, and Task values. Check the facets allowedValues payload of the Coveo API to verify whether the values are properly passed. The above code defines a specific list of allowedValues in the Search API request as a JSON string.
Removing the Search Box from Filter
In order to remove the search box from the above filter, please set withSearch={false}
<AtomicFacet withSearch={false} />
An extensive list of values in the facet filter can be unnecessary and may negatively impact the user experience. This not only improves the overall user experience but also reduces clutter, making it easier for users to find what they are looking for quickly and efficiently. Additionally, it can improve performance by narrowing down the search scope, leading to faster load times and more accurate results.