Action - Add Filter | Yext Hitchhikers Platform
What You’ll Learn
In this section, you will learn:
- How to structure the Add Filter action
- Example for Add Filter action
Action Structure
The Add Filter action has the following structure:
- The
filter
property accepts filter criteria based on the Knowledge Graph - The
verticals
property should be the verticals that are affected by the filter
Both properties are required.
Key | Type | Example |
---|---|---|
filter | Filter Object | “filter”: {“c_brand”: {“$eq”: “BrandName”}} |
verticals | Array of Strings | [“faqs”, “jobs”] |
The filter object is any valid filter that the Yext APIs will accept. You can see examples of how to construct these filters in our
developer documentation
. To use a Saved Filter, use the savedFilterId
property.
Config Structure
Here is an example of adding a filter using savedFilterId:
{
"actionType":"ADD_FILTER",
"verticals": [
"faqs",
"jobs",
"locations"
],
"filter":{
"savedFilterId":{
"$eq":"21466424"
}
}
}
Here is an example of adding a filter using a field:
{
"actionType": "ADD_FILTER",
"verticals": [
"locations",
"events"
],
"filter": {
"c_brand": {
"$eq": "BrandName"
}
}
}
Using the UI
When you select Add Filter as a query rule action in the UI, you’ll enter a code snippet similar to the ones above for the JSON Editor.
Add Filter Example
For a generic query like “Job FAQs”, we might want to curate the FAQs that appear using a saved search.
To choose these FAQs, we will:
- Check if the search term exactly matches “Job FAQs”
- Return results filtered down to the saved search I’ve created, ID equals 146669234
Below is how we would set up this query rule in the JSON editor, but you can also use the UI.
{
"criteria": {
"searchTermExactlyMatches": [
"jobs faqs"
]
},
"actions": [
{
"actionType": "ADD_FILTER",
"filter": {
"savedFilterId": {
"$eq": "146669234"
}
},
"verticals": [
"faqs"
]
}
]
},
After this rule is applied, only the FAQs in the saved search will be returned as a result.