SharePoint 2013 Query Spelling Inclusions for the masses
‘Did you mean’
One of the biggest investments in SharePoint 2013 was the integration of the enterprise-class search engine, previously known as FAST, with the SharePoint Search engine. As a result SharePoint 2013 Search offers us top of the class search capabilities.
Among all the different search-related capabilities of SharePoint 2013 Search are query spelling suggestions – also known as ‘did you mean’. Whenever you enter a search query, SharePoint 2013 Search will check if all words have been spelled correctly and if not, it will suggest the correct spelling.
And while the query spelling suggestions do work by default, there are some challenges to how they are configured.
Query spelling suggestions out of the box
SharePoint 2013 Search knows two types of query spelling suggestion dictionaries: a dynamic and a static one. The dynamic dictionary is maintained by SharePoint itself based on the content in the search index, while the static one is maintained by yourself. Out of the box SharePoint uses the dynamic query spelling suggestions dictionary.
For a term to become a part of the dynamic query spelling dictionary, it has to occur in at least 50 documents. The interesting part is however the content alignment process which is used by the dynamic dictionary and which is enabled by default. This process is triggered when the term that occurs the most in the search index has been found in the preconfigured number of documents (1000 by default; can be changed using PowerShell) and then the dictionary is built.
If you are interested in exploring the default configuration of query spelling suggestions you can use the following PowerShell snippet:
$ssa = Get-SPEnterpriseSearchServiceApplication Get-SPEnterpriseSearchQuerySpellingCorrection -SearchApplication $ssa
What if, however, you don’t want to rely on the standard process of building query spelling suggestions dictionary and want to build and maintain one yourself?
Query spelling suggestions in the manual mode
SharePoint 2013 uses two Global Term Sets called Query Spelling Exclusions and Query Spelling Inclusions to define the query spelling suggestions. Both Term Sets are ignored in the dynamic mode however, so before you can start entering your own suggestions, you have to switch to the static dictionary.
To switch to the static query spelling suggestions dictionary you have to run the following PowerShell snippet:
$ssa = Get-SPEnterpriseSearchServiceApplication Set-SPEnterpriseSearchQuerySpellingCorrection -SearchApplication $ssa -SpellingDictionary Static
This will change the query spelling suggestions dictionary mode to static and with this SharePoint 2013 Search will start using your values stored in the two Term Sets.
Configuring query spelling suggestions is easy and comes down to creating new Terms under the Query Spelling Exclusions Term Set (for words which you never want to have suggested) and the Query Spelling Inclusions Term Set (for words which SharePoint should suggest). There are a few rules when it comes to configuring query spelling suggestions:
- a query spelling suggestion is a single word, so SharePoint is a correct suggestion but Sharing Points is not
- when creating query spelling suggestions only the first level of Terms is taken into account. SharePoint 2013 Search expects a list of words that it can then use to detect spelling mistakes. Query spelling suggestions Terms are in no way a dictionary such as SharePint > SharePoint, where the Term SharePoint would be a child Term of SharePint denoting in a way that every time SharePoint 2013 Search stumbles upon SharePint in a search query it should suggest SharePoint instead. This part is done by SharePoint automatically without our help.
After you have entered your query spelling suggestions Terms, they won’t appear directly in the search results however. Instead you have to wait for the Search Custom Dictionaries Update Timer Job to run or execute it manually yourself. After the job has executed and the query spelling suggestions from the static dictionary have been processed they will be used in SharePoint search results.
SharePoint 2013 Search provides us with the query spelling suggestion capability that suggest correcting spelling mistakes in search queries. By default this capability is configured to automatically build the spelling suggestions dictionary. By changing the configuration settings it is possible to manually maintain the query spelling suggestions dictionary.