Facets, static filters, and inferred filters are all methods for refining search results using attributes of your content. There are important distinctions between them:
- Static Filters: Applied before the query is run, limiting the results that are searched on
- Facets: Generated after the query is run, refining the results that are returned
- Inferred Filters: Applied automatically by the search algorithm based on the best exact matches
You'll find all three on the Filters tab of a vertical configuration. Since they are all filters, these work best on enum or option fields with finite values.
Static Filters
Static filters are applied pre-search and are not dependent on the search query. They are defined on the client side, so whenever a user queries an experience, any enabled static filter is submitted as an additional filter with the query, restricting the results that are returned.
Good use cases for static filters include:
- Time filters for blog entity types (for example, only show blogs written in the last week)
- Location filters (for example, only show locations in a specific state)
Implement Static Filters
Via the Platform UI
- Click Search in the navigation bar and click on the desired Search experience. You'll land on the Verticals screen.
- Select the vertical you want to configure.
- Click the Filters tab.
- In the Static Filters section, click + Add/Update Fields.
- Check the fields you want to include and uncheck any you want to remove. Then click Update.
- Click Save.
To remove a field, click the trash can icon next to it on the Filters screen.
Via the JSON Editor
Fields are referenced by their API name. To set a field as a static filter, add it to the searchableFields object and set staticFilter to true:
"verticals": {
"products": {
"searchableFields": {
"c_category": {
"staticFilter": true
}
}
}
}
Frontend
After configuring the backend, add static filters to your frontend. See Facets and Filters (Frontend) for the Theme, or the StaticFilters React component reference.
You can also use static filters for filter search, where users select static filters to conduct their search. See the FilterSearch React component reference for more.
Facets
Facets are applied post-search, since they are dependent on the search query, and can be used to further refine results. They are returned by the API and then displayed client side. Each facet option shows a result count; if no results exist for a given option, that option will not appear.
Note: Facets are only supported on vertical search.
Facet Logical Operators
Within a single facet set, selecting multiple options returns results that match either option (OR logic). For example, selecting "outdoor seating" and "live music" under Restaurant Features shows locations that have either.
Across different facet sets, selecting options in both sets returns only results that match both selections (AND logic). For example, selecting "live music" under Restaurant Features and "food truck" under Restaurant Type shows only results that are both.
Facet Best Practices
Think about the types of queries your users are running and how they would want to refine results. In most cases, facets are encouraged. Balance the number of facets with your users' needs: having facets is helpful, but too many can be overwhelming.
For example, for a generic query like "I need a doctor," you might offer facets for Conditions Treated, Insurances Accepted, or Specialty. Other good use cases include:
- Sizes on a Products vertical: XS, S, M, L, XL
- Menu sections on a Menu Item vertical: Appetizers, Pasta, Pizza, Salads, Sides, Dessert
- Employment type on a Jobs vertical: Full Time, Part Time, Flexible Hours
- Services on a Locations vertical: Drive-thru, ATM
Types of Facets
Standard facets pull field values directly as facet options and are the most common type.
Numerical facets let you define static number ranges as facets, which is useful for price ranges, multipack quantities, and similar numeric attributes.
Hierarchical facets allow users to click through a hierarchy of categories to filter results. The most common use case is category fields. Hierarchical facets are only supported in Search UI React, not the Hitchhikers Theme.
Facet Order
You can customize the order in which facets appear on the frontend for each vertical. Facets at the top of the list get the most attention, so place the most general, high-level filter categories first and more specific ones lower. If you don't specify an order, the algorithm determines it.
Implement Facets
Via the Platform UI
- Click Search in the navigation bar and click on the desired Search experience. You'll land on the Verticals screen.
- Select the vertical you want to add facets to.
- Click the Filters tab.
- In the Facets section, click + Add/Update Fields. A dialog box appears.
- Check the fields you want to add as facets and uncheck any you want to remove. Then click Update.
- Click Save.
To set facet order in the UI, drag the facets into the order you want them to appear.
Via the JSON Editor
To set a field as a facet, add it to the searchableFields object and set facet to true. To control facet order, include a facetOrder array in your vertical with fields listed in the desired order. Any facets not listed in facetOrder will appear in an algorithm-determined order.
"verticals": {
"restaurants": {
"facetOrder": [
"c_restaurantType",
"c_restaurantFeatures"
],
"searchableFields": {
"builtin.entityType": {
"nlpFilter": true
},
"builtin.location": {
"nlpFilter": true
},
"c_restaurantFeatures": {
"facet": true,
"nlpFilter": true
},
"c_restaurantType": {
"facet": true
},
"name": {
"textSearch": true
}
}
}
}
Frontend
After configuring the backend, add facets to your frontend using the relevant resources for your implementation method:
- Hitchhikers Theme: Facets and Filters (Frontend) training unit. Supports standard and numerical facets. Hierarchical facets are not supported.
- Search UI React: StandardFacet, NumericalFacet, and HierarchicalFacet component reference docs.
- Search SDK: Facet component
- Search Endpoints: Universal Search API
- Search Core: search-core on GitHub
Inferred Filters
Inferred filters are applied automatically by the search algorithm based on the best exact matches in the results, rather than by the user. Like static filters and facets, they apply a strict filter that eliminates results that do not match.
Inferred Filter Order
When the same filter value exists in two different fields that are both enabled for inferred filters, the filter that gets applied is otherwise arbitrary. Use nlpFilterOrder to specify which field should take priority when conflicts occur.
A common example is healthcare clients who want to prioritize their own list of specialties over the Yext built-in list of medical conditions.
Implement Inferred Filters
Via the Platform UI
- Click Search in the navigation bar and click on the desired Search experience. You'll land on the Verticals screen.
- Select the vertical you want to configure.
- Click the Filters tab.
- In the Inferred Filters section, click + Add/Update Fields.
- Check the fields you want to include and uncheck any you want to remove. Then click Update.
- Click Save.
To set inferred filter order in the UI, drag the fields into the order you want them prioritized when conflicts occur.
Via the JSON Editor
To set a field as an inferred filter, add it to the searchableFields object and set nlpFilter to true. To control priority order, include an nlpFilterOrder array. All fields listed in this array must also have nlpFilter enabled.
"facilities": {
"entityTypes": [
"healthcareFacility"
],
"name": "Facilities",
"nlpFilterOrder": [
"specialties",
"builtinFile.medicalConditions"
],
"searchableFields": {
"builtinFile.medicalConditions": {
"nlpFilter": true
},
"specialties": {
"nlpFilter": true
}
},
"source": "YEXT"
}