Re-index related pages for Content Delivery API
# help-with-umbraco
d
Hi Umbracians, I'm following this example of extending Content Delivery API for indexing: https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api/extension-api-for-querying#custom-selector Everything works fine, and I've got "featured" property propagated from Author to Article. One thing I can't get working at the moment however is when I change the Author "featured" toggle, I need all the Articles that reference this Author to be re-indexed as well. Right now if I make the Author "featured" I need to rebuild Content Delivery API examine index entirely for this updated value to appear on Articles. I'm trying to implement ContentPublishedNotification for Author content items. Inside it I managed to find all the Articles that have this Author assigned, but how can I trigger index rebuild for these items? I was trying to call: umbracoIndexingHandler.ReIndexForContent(content, true); but it didn't seem to have any effect. What else can I try?
j
It's a common problem with referenced content, I have an example on how to reindex a bunch of nodes by ID at the end of this blogpost: https://dev.to/jemayn/the-problem-of-referenced-content-in-examine-indexing-umbraco-11-4355
d
Ace, thanks @Jemayn , this appears to be exactly what I needed, hopefully it still works in Umbraco 12 with Content Delivery API index, will give it a try
@Jemayn that still works, thank you! Only a couple of small things changed really: - publish notifications are async now - for the Content Delivery API I had to swap the index name constant to Constants.UmbracoIndexes.DeliveryApiContentIndexName - and instead of IPublishedContentValueSetBuilder use IDeliveryApiContentIndexValueSetBuilder, for some reason I thought there's only one value set builder, apparently there are separate value set builders for each index
j
Happy to hear it 🙂
6 Views