Sitecore 9 – Azure Search Suggestions

sitecore-azure-logo

As you already know Sitecore 9 is Microsoft Azure compatible, but when it comes to Azure Search than it has many limitations. One of those limitations is Azure Search highlighting, Azure Search Suggestions and some others…
On one of our projects we had to provide suggestions with the search. After some investigations we decided to build it on our own, instead to wait and see if it will come out with new versions of Sitecore.

The biggest problem was that Sitecore packages for Azure Search do not support building indexes with suggestions. In order to build an Azure Index with Suggester we have made a workaround and extended the Sitecore implementation of IndexDefinitionJsonConverter.


In order to create a suggester for the Azure index we had to create a config file with config node „suggesters“ and the child node for the fields „sourceFields“. In sourceFields we have added fields that will be added to the suggester on the Azure index.

After the code has been compiled and and everything is published you have to rebuild your index you want in order to have the suggester up and ruining on the Azure Search.

Azure Search Index With Suggester Azure Search Index With Suggester

When you rebuild your index from the sitecore back-end you should have your index rebuilt with the suggester and selected fields for suggestions.

Sitecore 9 Azure Search Suggestions Sitecore 9 Azure Search Suggestions
nameAsSuggestFiled Sitecore 9 Azure Search Suggestions

In order to call our suggester to give us results we had to build API calls manually.

Now the only thing left is to make your web api controller and to set API url which you will call when you need to get search suggestions and to build your front-end to give you the result in a json response.

Azure search suggestions in frontend Azure search suggestions in frontend

With this approach you can create your own web API call that will have highlighting or a count included.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>