Kentico 13 Azure Index Rotation

Matthew Butler asked on May 25, 2022 11:06

I'm currently looking to provide index rotation, to allow index B to be rebuilt as index A is in use.

I was thinking of overriding the SearchIndexInfoProvider, but this appears to use GetInfoById rather the Get(int Id) so I can't customise, and not sure how I'd identify rebuild operation vs others.

The other thought was a custom Azure Search Task, that sets the SearchIndexInfo prior to rebuild, but again this will set for all operations.

Any thoughts please?

Recent Answers


Sean Wright answered on June 9, 2022 05:59

This is an interesting question and I really wish the solution was baked into the platform. This is something that's possible with the Kentico Xperience 13 Algolia search integration, but that is designed very differently from the Azure Search integration.

I think your idea to customize SearchIndexInfoProvider is the only option, specifically the protected virtual TInfo GetInfoById(int id, bool useHashtable = true) method.

I think having a custom setting in the CMS that would let you set a 'primary' index which could be returned in GetInfoById might work.

Another (much simpler) option is to have 2 indexes that index the same content and use a CMS setting to switch the ASP.NET Core application to use the alternate index while the other is being rebuilt.

Since you are in full control of the ISearchIndexClient creation in the ASP.NET Core application, you can swap between indexes whenever/however you want.

0 votesVote for this answer Mark as a Correct answer

Matthew Butler answered on June 9, 2022 09:53

Thanks Sean,

I was looking at the IInfoProvider interface, so assumed I couldn't override the GetInfoById call.

I had thought of a 2nd index, but I felt there was a strong chance the 2 index configurations would fall out of sync.

I haven't looked in a while, but the other challenge I think I had with overriding the GetInfoById was identifying if the call was for a re-index

0 votesVote for this answer Mark as a Correct answer

Sean Wright answered on June 9, 2022 15:06

but I felt there was a strong chance the 2 index configurations would fall out of sync.

You could use Global Events or overriding the InfoProvider to keep them coordinated via some naming convention.

I do think that 2 indexes is probably the best approach until Xperience supports index rotation internally.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.