Configure results based on site and visitor contexts

Sitecore Search returns paginated 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 menu, 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 menu, 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.

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 menu, 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 menu, 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.

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 menu, select Add attributes manually.

  3. Click Add attribute, select Referring URL from the list and in the operator drop-down menu, 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. In the CEC, create or edit a global widget variation rule.

  2. In the top banner, on the right, in the Output entity dropdown, select an entity.

    Note

    Selection change in the Output entity dropdown:

    • 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 menu, click Is.

  3. Do not enter any values for the attribute.

  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 Funnel.

  7. Drag items to one of the slots.

  8. Click Save.

  9. 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.

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

  1. In the CEC, create a widget variation rule or edit 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 menu, click Is.

  4. Do not enter any values for the attribute.

  5. On the menu bar, click Strategies.

  6. In the left pane, click the Slots tab.

  7. 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 Funnel.

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

  8. Drag items to one of the slots.

  9. Click Save.

  10. To deploy, click Publish.

Do you have some feedback for us?

If you have suggestions for improving this article,