Display relevant results
Textual relevance refers to how closely a potential result matches the visitor's search query. When you configure textual relevance, you tell Sitecore Search where in the content it needs to look for matching terms, and the relative importance it needs to give different content areas.
Textual relevance is not the same as relevancy score, despite the similar names.
For example, if you want Sitecore Search to look for matching terms in the names and descriptions of your content items, configure the name and description attributes for textual relevance.
To preserve the relevance of search results, we recommend using attributes with short values. The longer an attribute's values are, the more likely it is that they contain irrelevant information and the less useful they are for textual relevance.
You can specify multiple attributes for use with the textual relevance feature and give each attribute a weight in the global widget. This weight is used with other factors to calculate the relevancy score of each content item, which determines the order of the content items in search results.
For example, the Sitecore.com search page has several attributes configured for use with textual relevance. These attributes are, in order of descending weight, title, description, and subtitle. In other words, if a visitor searches for the term DXPs, Search looks for that term in the values of title, description, and subtitle. Search assigns more weight to content items that have the search term in the title compared to those that have it in the description or subtitle. If the search term appears in more than one attribute, the weights are added. This means that a content item with the search term in all three attributes is generally assigned the maximum weight for that search query.
However, textual relevance is not only based on whether a search term is present in the field. The context in which the term appears might also have an effect on the relevance of the content item; Sitecore Search can determine whether the term is a primary subject of the attribute or an incidental mention.
The following image shows a search for DXPs on the Sitecore.com search page. Notice that the top three search results include the search term in the title and the description.
Search only looks for search terms in attributes that are enabled for textual relevance. For example, although Sitecore.com content items have a product attribute, it isn't used in textual relevance, so Search doesn't look for search terms in product values.
Each entity uses a distinct set of attributes for textual relevance. For example, the content entity uses the name, description, and tags attributes by default. You can configure the attributes used by each entity as required.
Using the textual relevance feature
After you complete the initial setup of Sitecore Search on your site, you might find that your search results are either incomplete or include irrelevant content items. If this happens, you can fine-tune results by making changes to your textual relevance setup.
If your search results are incomplete, try setting up the textual relevance feature to use more attributes.
Even if your search results are still incomplete after adding targeted attributes, we advise against creating an attribute that represents the full text of your content item, such as the body
tag of an HTML-based webpage. Doing this can cause irrelevant search results because the search term might appear in a menu, a sidebar, or even in the HTML tags themselves.
To avoid this, you can create an attribute that precisely targets the text you want to extract. For example, there might be a particular <div>
element within the <body>
that contains the main text of your article or post. If there is, you can extract the contents of that <div>
element instead of the contents of the entire <body>
element. This helps ensure that search results are as relevant as possible. Then, when enabling that attribute for textual relevance in the global widget, we recommend that you assign that attribute a lower weight compared to other attributes. This way, content items that have the search term in a more relevant field, like the title, will show up higher in search results compared to content items that only mention the search term in the body text.
Optimizing search results using the textual relevance feature can be an iterative process. After adding a new attribute for use with textual relevance, you might find that your search results have become less relevant. If this happens, you can try decreasing the weight of the attribute. If you are still getting irrelevant search results, you might need to refine your data more or remove the attribute altogether.