A walkthrough of Azure Search features & setup with Sitecore

In this article we will go over the basics of Search engines and Indexes followed by a quick guide to using Azure search with your Sitecore solution, how to set it up and things to consider if you are switching an existing solution from a different search engine to Azure Search.

Search Engines with Sitecore

What are search engines & indexes? Why are they used and what do they help us achieve?

Here is a short introduction.

Sitecore’s content is stored is SQL databases. While fetching single units of content from the database directly is quite economical – given Sitecore’s caching mechanism, trying to run queries on the content gets quite expensive on resources (more so depending on the amount of content available on your instance).

Indexes store the content from your content tree in flat files. Running queries and fetching information from flat files, is a lot faster and demands lesser resources as well.

When we run searches on our content or even display content from a large number of items, such as listings etc, fetching this content from indexes is the way to go.

There are several search engines (options being Lucene – which is being phased out, SOLR & Azure search) which facilitate this process:

  • Indexing – Getting the data from the database into the index files
  • Querying on indexes – Fetching data from indexes to display on the site.

With solutions moving towards service-based cloud instances, this leaves us with SOLR & Azure Search.

While SOLR cloud is evolving, and there are also third party SOLR cloud services available in the market, Sitecore does seamlessly integrate with Azure search as a cloud-based service.

Azure Search

The Sitecore Azure Search provider integrates the Sitecore Search engine with the Microsoft Azure Search service.

Here are some considerations before you make the jump to Azure Search.

There are no two ways to it, Azure Search is pricey.

With the limits on number of indexes allowed, and the limit on the number of fields that can be indexed, it makes S1 tier the first viable option for use with Sitecore.

1

Figure 1 Azure Search – Limits, Quotas & Capacity

Reference: https://docs.microsoft.com/en-us/azure/search/search-limits-quotas-capacity

Apart from this, if you are migrating from a previous SOLR instance to Azure Search, there are certain limitations to be mindful of. While the list is documented by Sitecore, the below are very commonly used and do deserver a callout:

  • Media indexing is not supported
  • Same name fields not supported – which is to say that there cannot be such things as fields that have the same name but different types in different documents.
  • Geo spatial search is not supported – all that hoopla about how easy geo spatial search had gotten with Sitecore 9 and SOLR is moot with Azure Search for now.
  • Azure Search indexes support a maximum of 1000 fields per index – this can be quite a deterrent while using with Sitecore. But – there are ways to work around this – by either setting indexAllFields to ‘false’ or creating custom web / master indexes (to support computed fields).

These considerations definitely should be accounted for while preparing for a migration from SOLR.

Use Case

As for setup, you need to create an Azure search service in the azure portal.

2

Figure 2 Login to the Azure portal

3

Figure 3 Search for the Azure Search service

4

Figure 4 Fill in the relevant information to create the Azure search service

5

Figure 5 All configuration completed, Create the service

6

Figure 6 Azure search service created

The url of this service needs to be configured in the Sitecore config.

Here’s how to build the connection string:

<add name=”cloud.search” connectionString=”serviceUrl=<url>;apiVersion=<apiVersion>;apiKey=<apiKey>” />

7

Figure 7 Get the service url in the Overview tab

8

Figure 8 Get the API key in the Keys tab – you can use either the primary or secondary key

9

Figure 9 Get the API version from the Search Explorer tab

Here are the updates required in the Sitecore configuration:

10

Figure 10 Sample connection string

11

Figure 11 Web.config – configuration update to flip to Azure Search

Once this is done, you are all set to rebuild indexes from Sitecore!

12

Figure 12 Indexes rebuilding in Sitecore – with Azure search configured

13

Figure 13 Indexes rebuilt successfully

The indexes are now available in azure (created automatically)

14

Figure 14 Indexes now available in Azure Portal

So as demonstrated, configuring Azure search is relatively pain free, however there is definitely a cost that comes with it, and additionally, some considerations need to be made. While SOLR is now the out of the box option for a vanilla Sitecore instance, Azure Search does integrate seamlessly with the Microsoft stack and is definitely a great option to consider.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s