Understand suggestions blocks
In Sitecore Search, you use suggestions blocks to provide site visitors with relevant suggestions in the search bar.
You can create suggestions blocks based on four different types of algorithms: Sort by attribute, Edit distance, Context aware, and Recent history. These algorithms work to recommend popular content items, correct typos, return personalized auto-completed suggestions, and return keywords based on the user's previous full page searches respectively.
All suggestions block algorithms work with attributes to generate suggestions. To create a seamless search experience, we recommend that you use the same attributes for suggestions blocks as you use for textual relevance.
Sort by attribute
Use the Sort by attribute suggestions block to show suggestions to visitors based on a specific attribute. For example, if a visitor clicks in the search bar but hasn't yet typed anything, a Sort by attribute suggestions block can show top content items by the number of clicks over the last week.
Edit distance
Use the Edit distance suggestions block to provide a Did you mean... typo correction experience to visitors. For example, if a visitor is searching for content items about ecommerce and types ecomnerce by mistake, an Edit distance suggestions block can suggest the correct spelling, ecommerce.
It's important to use suggestions blocks for typo correction and not resort to relaxing the rules in the textual relevance feature, because that can generate poor search results.
Context aware
Use a Context aware suggestions block to create personalized auto-completion of search queries. For example, if a visitor types digital in the search bar, a Context aware suggestions block can display suggestions such as digital asset management or digital commerce. These suggestions are based on data from content items in your index.
Recent history
The Recent history suggestion block displays keywords previously searched for by the user. Only keywords from full-page searches are included. For example, if the suggestion block is configured to display the 10 most recent items and the user has performed 10 full-page searches in total, then, the Recent history suggestion block displays all 10 search keywords.
A full-page search is one that displays the search results page after a user submits a query in the search bar, typically by pressing Enter.
Creating suggestions blocks
You create suggestions blocks on the Feature configuration tab of the Domain Settings section of the Administration page.
When you create a suggestions block of any type, the following options are available:
-
Number returned - number of suggestions to be returned. This number can be overridden at runtime.
-
Blacklist - list of strings you don't want to be shown in the suggestions
-
Analyzers - list of analyzers you want to make available for use by the grouping analyzer and match analyzer.
-
Build suggestions from - attribute(s) to use to generate suggestions. For example, if you set this to a title attribute, the suggester creates relevant suggestions using content items' titles.
-
Grouping analyzer - analyzer to use to process suggestions to return in the response. For example, if you use the keyword analyzer on the title attribute, content items' titles are kept whole when generating suggestions rather than breaking them up into several-word phrases.
-
Match analyzer - analyzer to use to process the search input text and match it with a suggestion value.
The Recent history suggestion block only contains the Number returned and Blacklist options.
When you create a Context aware or Edit distance suggestions block, the following additional option is available:
-
Include exact match - determines whether suggestions that exactly match the user’s input are included in the response.
NoteExact match behavior depends on the selected match analyzer. Analyzers that preserve the full input as a single token (such as Keyword) are required for true exact‑phrase matching. Tokenizing analyzers such as Prefix Match or Ngram may prevent exact matches from being returned, even when this option is enabled. For more information see Types of analyzers.
Max distance is the maximum number of edits allowed to consider a suggestion valid. Sitecore Search uses the default max distance value of 2. This only applies to the Edit distance suggestion blocks.
When you create a Sort by attribute suggestions block, the following additional options are available:
-
Aggregation function - operation used to compute the overall ranking of a suggestion.
-
Attribute - the numeric attribute to use for sorting, usually some sort of statistical attribute such as views or clicks.
-
Order - direction to sort by, either ascending or descending.
Configuring suggestions blocks in a widget
After you have created a suggestions block and reindexed your sources, that suggestions block is active across your domain and available for a developer to request at runtime. You do not need to do any further configuration.
You can turn the suggestions block on or off in the Global Widget settings. A developer can request all suggestions blocks that are turned on using a blank object at runtime.
You can also turn a suggestions block on or off for a certain context using a rule in the Preview Search widget.
When you configure a suggestions block in a rule, the following options are available:
-
Number returned - the number of suggestions returned. You can use this field to customize how many suggestions are returned in specific widgets.
-
Blacklist - enables you to remove specific suggestions from results. You can use this at the widget level to remove those suggestions from certain contexts.