Context Setting to Hide all Vertical Results

Hi Andrew,

Welcome to the Community! This is a great use case to use context in query rules to address both of these scenarios. Your client will need to set context in their integration and you can set up query rules in the search config to determine what content is pulled in.

Context: The client will want to pass as context a true/false field stating whether the user is a subscriber (e.g. is_subscriber field). Your client will need to set context in their integration (instructions here), which you can test based on the instructions in this community post.

Query Rules: Since you want the search behavior to differ based on whether the user is on universal or vertical search, you’ll need two query rules.

  1. Suppressing content on universal search - use ADD_FILTER action for non-premium content when context criteria is is_subscriber: false (or a filter for premium content when true, depending on how you decide to set it up). You could do this either by adding a saved filter for non-premium content OR by adding a custom field that designates whether content is premium or non-premium.

  2. Displaying no results in “Company Updates” vertical - In addition to the context criteria like above, use "searchTypes"="VERTICAL" criteria with RETURN_NO_RESULTS action. However, it may be more useful to return an entity that tells users this section contains content only available to subscribers, with a CTA encouraging users to subscribe, as this may help drive conversions. In this case you can use the ADD_FILTER action with a filter for that one entity.*

*Note: Keep in mind that the ADD_FILTER action will return the intersection of the new filter and the original results. That means the content not available entity would only be returned for relevant search queries, not all search queries. To surface this entity for all search queries for non-subscribers, you’ll need to boost the entity.

Putting all of that together, your query rules will look something like:

"rules": [
    {
      "criteria": {
        "contextMatches": {
          "$.is_subscriber": {
            "$eq": false
          }
        }
      },
      "actions": [
        {
          "actionType": "ADD_FILTER",
          "filter": {
            "savedFilterId": {
              "$eq": "279927352"
            }
          },
          "verticals": [
            "company_updates"
          ]
        }
      ],
      "name": "Hide Company Update"
    },
    {
      "criteria": {
        "contextMatches": {
          "$.is_subscriber": {
            "$eq": false
          }
        },
        "searchTypes": "VERTICAL"
      },
      "actions": [
        {
          "actionType": "BOOST_ENTITIES",
          "entityIds": [
            "pinned-result"
          ],
          "verticalKey": "company_updates"
        }
      ],
      "name": "Content Not Available on Vertical"
    }
  ],

You can Query Rules in the Query Rules module. Feel free to reach out with any questions as you’re setting this up!