---
title: "Configure results using context"
slug: "configure-results-using-context"
abstract: "How to configure results based on site and visitor contexts in Sitecore Search."
---
# Configure results using context

Sitecore Search returns paginated results for a search keyphrase in its widgets. You can use widget variation rules to fetch search results based on user-defined or context-driven queries.

In the **Context** section, on the **Site** and **Visitor** tabs, to define the criteria used to evaluate the application of the rule, add an attribute and use an operator to relate a value to it. You can add as few or as many attributes you want.

> [!note]
> If you do not add any attributes in the **Context** section, the rule applies to all site areas and to all visitors.

The following procedures cover various typical scenarios to to optimize results. They include defining **Context** as criteria for variation rule application.

## Define site context for a variation rule

In the **Context** section of a widget variation rule, you can control when a rule applies. You can think of this section as the trigger for the rule.

To define site context for a widget variation rule:

1. On the rule definition page to edit a widget variation rule, on the menu bar, click **Context**.
2. On the **Site context** tab, click **Add attribute**, select an attribute from the list and in the operator drop-down list, select an operator.
3. To set the attribute value, in the text box, type a value or begin typing to select one or more available values.
4. To add more attributes, repeat from step 2.

## Define visitor context for a variation rule

In the **Context** section of a widget variation rule, you can control when a rule applies. You can think of this section as the trigger for the rule.

To define visitor context for a widget variation rule:

1. On the rule definition page to edit a widget variation rule, on the menu bar, click **Context**.
2. On the **Visitor context** tab, click **Add attribute**, select an attribute from the list and in the operator drop-down list, select an operator.
3. To set the attribute value, in the text box, type a value or begin typing to select one or more available values.
4. To add more attributes, repeat from step 2.

## Boost results for certain URLs

This procedure creates a widget variation with a rule. When this widget variation is *Active* and a user browses in the configured URL or URL pattern, items with an Id value that is configured in the rule will appear at the top of all results.

Before configuring a widget variation rule strategy:

1. [Create or edit a widget variation rule](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/understanding-context-in-search/add-or-edit-widget-variations.html#UUID-106bcec2-8ef6-3dc7-4803-5d9817dd5a1a_section-idm4537295734779233697204820873 "Add a widget variation rule").
2. In the top banner, on the right, in the **Output entity** drop-down list, select an entity.

    > [!note]
    > Selection change in the **Output entity** drop-down list:
    >
    > -   Displays the number of entity items matching the rule.
    >
    > -   Populates the rule with selected entity items.
    >
    >
    > The items in the slots of a new rule do not necessarily reflect those at runtime.

To boost results for certain URLs:

1. On the menu bar, click **Context**.
2. On the **Site context** tab, click **Add attribute**, select *Pages* from the list and in the operator drop-down list, click **Is**.
3. To set the attribute value, in the text box, begin typing the page name then select one or more pages configured to render for the URLs.

    > [!note]
    > A page is strictly associated with a URL or URL pattern. Selecting a page is essentially the same as selecting the URL or URL pattern.

4. On the menu bar, click **Strategies**.
5. On the **Boost rules** tab, click **Add attribute**, select *Id* from the list and in the operator drop-down list, click **Is**.
6. To set the attribute value, in the text box, enter the *Id* of an item.

    > [!note]
    > You can search, filter, and browse items in the right-hand pane. In an item card, hover the mouse over **Quick look** to get its *Id* property.

7. Click **Save** and then click **Publish**.
8. To deploy, click **Publish**.

## Rank results based on a referring URL

This procedure creates a widget variation with a rule. When the widget variation is *Active*, if the visitor arrives from the specified referring URL, the results are ranked according to the search ranking of the rule.

Before configuring a widget variation rule strategy:

1. [Create or edit a widget variation rule](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/understanding-context-in-search/add-or-edit-widget-variations.html#UUID-106bcec2-8ef6-3dc7-4803-5d9817dd5a1a_section-idm4537295734779233697204820873 "Add a widget variation rule").
2. In the top banner, on the right, in the **Output entity** drop-down list, select an entity.

    > [!note]
    > Selection change in the **Output entity** drop-down list:
    >
    > -   Displays the number of entity items matching the rule.
    >
    > -   Populates the rule with selected entity items.
    >
    >
    > The items in the slots of a new rule do not necessarily reflect those at runtime.

To rank results based on a referring URL:

1. On the menu bar, click **Context**.
2. On the **Visitor context** tab, in the drop-down list, select *Add attributes manually*.
3. Click **Add attribute**, select *Referring URL* from the list and in the operator drop-down list, click **Is**.
4. To set the attribute value, in the text box, begin typing a referring URL, and select one or more values.
5. On the menu bar, click **Settings**, then on the **Search ranking** tab, turn on the **Enable configuration** switch.
6. To influence ranking results, for one attribute, on the slider choose a value.
7. Click **Save**.
8. To deploy, click **Publish**.

## Display specific items when a search keyphrase is empty

There are two ways to display results without a search keyphrase. Your choice depends on the specific business case:

- To display the same results in all widgets, configure a rule in a global widget variation.
- To display the unique results for a widget, configure a rule in a widget variation.

### Configure a global widget variation rule to display items

The following procedure creates a global widget variation with a rule. When this global widget variation is *Active*, if the visitor presses **Enter** without typing a keyphrase in the search field, the results include items configured in the **Slots** tab of the **Strategies** section of the rule.

Before configuring a widget variation:

1. [Create or edit a global widget variation rule](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/understanding-context-in-search/add-or-edit-widget-variations.html#UUID-106bcec2-8ef6-3dc7-4803-5d9817dd5a1a_section-idm4580056818259233697211368481 "Create or edit a global widget variation rule").
2. In the top banner, on the right, in the **Output entity** drop-down list, select an entity.

    > [!note]
    > Selection change in the **Output entity** drop-down list:
    >
    > -   Displays the number of entity items matching the rule.
    >
    > -   Populates the rule with selected entity items.
    >
    >
    > The items in the slots of a new rule do not necessarily reflect those at runtime.

To display results when a visitor triggers a search without a keyphrase:

1. On the menu bar, click **Context**.
2. On the **Site context** tab, click **Add attribute**, select *Keywords* from the list and in the operator drop-down list, click **Is Empty**.
3. On the menu bar, click **Strategies**.
4. In the left pane, click the **Slots** tab.
5. In the right pane, on the **Content items** tab, to filter the list by name, in the search input field, enter text or to filter the list by other attributes, click ![Filter](https://doc.sitecore.com/api/markdown-image/search/en/users/search-user-guide/images/Funnel.png).
6. Drag items to one of the slots.
7. Click **Save**.
8. To deploy, click **Publish**.

### Configure a widget variation rule to display items

The following procedure creates a widget variation with a rule. When this widget variation is *Active*, if the visitor presses **Enter** without typing a keyphrase in the search field, the results include items configured in the **Slots** tab of the **Strategies** section of the rule.

Before configuring a widget variation rule strategy:

1. [Create or edit a widget variation rule](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/understanding-context-in-search/add-or-edit-widget-variations.html#UUID-106bcec2-8ef6-3dc7-4803-5d9817dd5a1a_section-idm4537295734779233697204820873 "Add a widget variation rule").
2. In the top banner, on the right, in the **Output entity** drop-down list, select an entity.

    > [!note]
    > Selection change in the **Output entity** drop-down list:
    >
    > -   Displays the number of entity items matching the rule.
    >
    > -   Populates the rule with selected entity items.
    >
    >
    > The items in the slots of a new rule do not necessarily reflect those at runtime.

To display results when a visitor triggers a search without a keyphrase:

1. [Create or edit a widget variation rule](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/understanding-context-in-search/add-or-edit-widget-variations.html#UUID-106bcec2-8ef6-3dc7-4803-5d9817dd5a1a_section-idm4537295734779233697204820873 "Add a widget variation rule").
2. On the menu bar, click **Context**.
3. On the **Site context** tab, click **Add attribute**, select *Keywords* from the list and in the operator drop-down list, click **Is Empty**.
4. On the menu bar, click **Strategies**.
5. In the left pane, click the **Slots** tab.
6. In the right pane, on the **Content items** tab, to filter the list by name, in the search input field, enter text or to filter the list by other attributes, click ![Filter](https://doc.sitecore.com/api/markdown-image/search/en/users/search-user-guide/images/Funnel.png).

    For details and a performance analytics summary of an item, click **Quick Look**.

7. Drag items to one of the slots.
8. Click **Save**.
9. To deploy, click **Publish**.