Tuesday, May 29, 2018

Sitecore and Azure Search - An index can have at most 1000 fields

When attempting to run a rebuild of the master and web indexes in a PAAS environment of Sitecore 9 using Azure search, as the search was nearing the end, the following error would stop the index in it's tracks.
Exception: Sitecore.ContentSearch.Azure.Http.Exceptions.AzureSearchServiceRESTCallExceptionMessage: {"error":{"code":"","message":"The request is invalid. Details: definition : Invalid index: The index contains 1087 field(s). An index can have at most 1000 fields.\r\n"}}
As it turns out, Azure Search can only index a maximum of 1000 unique field names. Annoyingly enough, the OOTB Sitecore 9 with Experience Commerce appears to actually go over this limit - hence the error.

There are a couple of configuration patch files that come OOTB that attempt to cull down the number of fields by excluding a whole lot of them:

  1. App_Config/Include/Sitecore.XA.Foundation.Search.Azure.Index.Master.ExcludeFields.config
  2. App_Config/Sitecore/ContentSearch.Azure/Sitecore.ContentSearch.Azure.Index.Master.ExcludeFields.config
Which is a start, but it means the next step is for you to create your own version of one of these field exclude configs and start adding your custom fields (and any others you can find for that matter). In my case it took a number of deploys, because as the index was able to progress further the error kept rearing it's ugly head. Ultimately I settled on 200 odd excludes, which were made up with a combination of my custom fields and OOTB Sitecore fields.

A handy tip is to keep the Sitecore show configuration page open, and before you exclude a field, do a quick search on that page to ensure it has not already been excluded.

This isn't an elegant solution, but I will update this page if a patch is provided.

No comments:

Post a Comment