Installing Azure Search in Sitecore

Azure search became a new option as of Sitecore 8.2 update 1.  It’s a great search provider with all kinds of features out of the box.  Most notably:

  • Supports Lucene query syntax for queries
  • Autocomplete and type-ahead
  • Hit highlighting (show the context in which the keywords appeared)
  • Geo-spacial awareness (show geographical search results to a user)

While Azure search can be utilized by any install of sitecore, it is most notably useful in an azure cloud implementation.  Which has also changed in 8.2 update 1 and my friend and fellow MVP Bas Lijten wrote an amazing blog post about.  Important note, this install can be done automatically if you’re using the Azure ARM scripts that Sitecore provides.  In other words If your Sitecore is on Azure, make it easy on yourself and use the ARM scripts.

I’m also extremely happy to say that it’s quite easy to set up Azure Search in Sitecore.  Those of you who went through the toil of setting up Solr should be particularly pleased about that.

Get it installed

Step 1

Install Azure Search on an azure subscription.

  • Add new
  • Web + Mobile
  • Select Azure Search
  • Click Create

installing

Step 2

Get your access id

  • Find your new Azure Search in the resources list
  • Click Settings
  • Click Keys
  • Copy your primary key

configure

Step 3

Add connection string

  • serviceUrl – The url which Azure has given your search service, see above screenshot for where to find it (it’s blurred out, you can’t use mine!)
  • apiVersion – The version of the rest api to utilize for Azure search.  You’re unlikely to need to change this right now
  • apiKey – The key you retrieved in step 2
<connectionStrings>
	<!-- Your other connection strings -->
	<add name="cloud.search" connectionString="serviceUrl=https://********.search.windows.net;apiVersion=2015-02-28;apiKey=***********************************" />
</connectionStrings>

Step 4

Configure Sitecore

  • Remove or disable
    • App_Config\Include\Sitecore.Speak.ContentSearch.Lucene.config
    • App_Config\Include\ContentTesting\Sitecore.ContentTesting.Lucene.IndexConfiguration.config
    • App_Config\Include\FXM\Sitecore.FXM.Lucene.DomainsSearch.DefaultIndexConfiguration.config
    • App_Config\Include\FXM\Sitecore.FXM.Lucene.DomainsSearch.Index.Master.config
    • App_Config\Include\FXM\Sitecore.FXM.Lucene.DomainsSearch.Index.Web.config
    • App_Config\Include\ListManagement\Sitecore.ListManagement.Lucene.Index.List.config
    • App_Config\Include\ListManagement\Sitecore.ListManagement.Lucene.IndexConfiguration.config
    • App_Config\Include\Social\Sitecore.Social.Lucene.Index.Analytics.Facebook.config
    • App_Config\Include\Social\Sitecore.Social.Lucene.Index.Master.config
    • App_Config\Include\Social\Sitecore.Social.Lucene.Index.Web.config
    • App_Config\Include\Social\Sitecore.Social.Lucene.IndexConfiguration.config
    • App_Config\Include\Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config
    • App_Config\Include\Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.Xdb.config
    • App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Analytics.config
    • App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Core.config
    • App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Master.config
    • App_Config\Include\Sitecore.ContentSearch.Lucene.Index.Web.config
    • App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.Index.Master.config
    • App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.Index.Web.config
    • App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Lucene.IndexConfiguration.config
    • App_Config\Include\Sitecore.Marketing.Lucene.Index.Master.config
    • App_Config\Include\Sitecore.Marketing.Lucene.Index.Web.config
    • App_Config\Include\Sitecore.Marketing.Lucene.IndexConfiguration.config
  • Enable
    • App_Config\Include\Sitecore.ContentSearch.Azure.DefaultIndexConfiguration.config.disabled
    • App_Config\Include\Sitecore.ContentSearch.Azure.Index.Analytics.config.disabled
    • App_Config\Include\Sitecore.ContentSearch.Azure.Index.Core.config.disabled
    • App_Config\Include\Sitecore.ContentSearch.Azure.Index.Master.config.disabled
    • App_Config\Include\Sitecore.ContentSearch.Azure.Index.Web.config.disabled
    • App_Config\Include\Sitecore.Marketing.Azure.Index.Master.config.disabled
    • App_Config\Include\Sitecore.Marketing.Azure.Index.Web.config.disabled
    • App_Config\Include\Sitecore.Marketing.Azure.IndexConfiguration.config.disabled
    • App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Azure.Index.Master.config.disabled
    • App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Azure.Index.Web.config.disabled
    • App_Config\Include\Sitecore.Marketing.Definitions.MarketingAssets.Repositories.Azure.IndexConfiguration.config.disabled
    • App_Config\Include\ContentTesting\Sitecore.ContentTesting.Azure.IndexConfiguration.config.disabled
    • App_Config\Include\FXM\Sitecore.FXM.Azure.DomainsSearch.DefaultIndexConfiguration.config.disabled
    • App_Config\Include\FXM\Sitecore.FXM.Azure.DomainsSearch.Index.Master.config.disabled
    • App_Config\Include\FXM\Sitecore.FXM.Azure.DomainsSearch.Index.Web.config.disabled
    • App_Config\Include\ListManagement\Sitecore.ListManagement.Azure.Index.List.config.disabled
    • App_Config\Include\ListManagement\Sitecore.ListManagement.Azure.IndexConfiguration.config.disabled
    • App_Config\Include\Social\Sitecore.Social.Azure.Index.Master.config.disabled
    • App_Config\Include\Social\Sitecore.Social.Azure.Index.Web.config.disabled
    • App_Config\Include\Social\Sitecore.Social.Azure.IndexConfiguration.config.disabled

Step 5

Rebuild your index

  • From desktop Sitecore button -> Control Panel.  From launchpad click the Control Panel button
  • Indexing
  • Indexing Manager
  • Select all indexes
  • Execute

Now you’re good to go!

Sitecore doesn’t ship with wrappers to achieve the advanced search features that Azure Search provides, so you’ll likely need to create your own search service to utilize these features until Sitecore has a plan to wrap this in it’s linq to search feature.

Watch out!

If you have a custom search field with a preceding underscore, you need to make sure you give it an additional attribute of cloudFieldName like you can see on Sitecore’s _templatename field.  This is because Azure Search actually doesn’t allow a field to start with an underscore.

              <field fieldName="_templatename"        cloudFieldName="templatename_1"      boost="1f" type="System.String"   settingType="Sitecore.ContentSearch.Azure.CloudSearchFieldConfiguration, Sitecore.ContentSearch.Azure" />