XbK Azure AI Search - How to trigger index updates when using XbK APIs in external apps?
I've got an XbK site (let's call it Site A) that uses the Azure AI Search integration for XbK library to index some of the page content. I've got a second external non-Kentico site (Site B) with custom UI/functionality that allows users to edit and publish some pages from the XbK site, completely outside of the Kentico admin. Site B connects directly to Site A's Kentico database, and uses the Pages API for updating the page drafts and publishing pages.
When I publish the pages directly in the Kentico admin on Site A, the connected Azure AI Search index updates successfully. However, when publishing the same pages externally on Site B using the Pages API, the Azure AI Search index does not get updated.
Do I need to duplicate the AzureSearchSearchModule (https://github.com/Kentico/xperience-by-kentico-azure-ai-search/blob/main/src/Kentico.Xperience.AzureSearch/AzureSearchSearchModule.cs) in Site B to get this to work? Or is there a way to trigger the event handlers defined in the AzureSearchSearchModule in Site A, when events are triggered via Kentico APIs? Any other solutions?
Answers
How about exposing a webhook endpoint on Site A that triggers an index rebuild when called? This way, Site B can send a request to that endpoint after completing updates via the Pages API.
I encountered a similar issue with rebuilding a Lucene index on a SaaS environment, and this was my solution: https://www.milanlund.com/knowledge-base/handling-search-index-rebuilds-in-xperience-by-kentico-s-saas-environment
Thanks Milan, I ended up implementing your suggestion. I added a code-only module to Site B that registers handlers for the applicable content item/web page events (e.g. Publish, Unpublish, Delete). These event handlers then call a custom endpoint on Site A that does the actual work of rebuilding the Azure index.
I still need to look into adding improved resiliency, but the core concept is working.
To answer this question, you have to login first.