Action - Add Filter| 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 action

Add Filter Example

For a generic query like “Job FAQs”, we might want to curate the FAQs that appear using a saved search.

Jobs FAQs without Rule

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.

Jobs FAQs with Rule

unit Quiz
+20 points
Daily Quiz Streak Daily Quiz Streak: 0
Quiz Accuracy Streak Quiz Accuracy Streak: 0
    Error Success Question 1 of 2

    What properties are needed to utilize the Add Filter action? Select all that apply.

    Error Success Question 2 of 2

    Which of the following would be used to set a filter to return entities with “Turtlehead Tacos” as the exact value in a custom field?

    Climbing that leaderboard! 📈

    You've already completed this quiz, so you can't earn more points.You completed this quiz in 1 attempt and earned 0 points! Feel free to review your answers and move on when you're ready.
1st attempt
0 incorrect