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.
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:
-
On the rule definition page to edit a widget variation rule, on the menu bar, click Context.
-
On the Site context tab, click Add attribute, select an attribute from the list and in the operator drop-down menu, select an operator.
-
To set the attribute value, in the text box, type a value or begin typing to select one or more available values.
-
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:
-
On the rule definition page to edit a widget variation rule, on the menu bar, click Context.
-
On the Visitor context tab, click Add attribute, select an attribute from the list and in the operator drop-down menu, select an operator.
-
To set the attribute value, in the text box, type a value or begin typing to select one or more available values.
-
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:
-
On the menu bar, click Context.
-
On the Site context tab, click Add attribute, select Pages from the list and in the operator drop-down menu, click Is.
-
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.
NoteA page is strictly associated with a URL or URL pattern. Selecting a page is essentially the same as selecting the URL or URL pattern.
-
On the menu bar, click Strategies.
-
On the Boost rules tab, click Add attribute, select Id from the list and in the operator drop-down menu, click Is.
-
To set the attribute value, in the text box, enter the Id of an item.
NoteYou 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.
-
Click Save and then click Publish.
-
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:
-
On the menu bar, click Context.
-
On the Visitor context tab, in the drop-down menu, select Add attributes manually.
-
Click Add attribute, select Referring URL from the list and in the operator drop-down menu, click Is.
-
To set the attribute value, in the text box, begin typing a referring URL, and select one or more values.
-
On the menu bar, click Settings, then on the Search ranking tab, turn on the Enable configuration switch.
-
To influence ranking results, for one attribute, on the slider choose a value.
-
Click Save.
-
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:
-
In the top banner, on the right, in the Output entity dropdown, select an entity.
NoteSelection 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:
-
On the menu bar, click Context.
-
On the Site context tab, click Add attribute, select Keywords from the list and in the operator drop-down menu, click Is.
-
Do not enter any values for the attribute.
-
On the menu bar, click Strategies.
-
In the left pane, click the Slots tab.
-
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 .
-
Drag items to one of the slots.
-
Click Save.
-
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:
-
On the menu bar, click Context.
-
On the Site context tab, click Add attribute, select Keywords from the list and in the operator drop-down menu, click Is.
-
Do not enter any values for the attribute.
-
On the menu bar, click Strategies.
-
In the left pane, click the Slots tab.
-
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 .
For details and a performance analytics summary of an item, click Quick Look.
-
Drag items to one of the slots.
-
Click Save.
-
To deploy, click Publish.