Hooky
11/26/2024, 12:11 PMD_Inventor
11/26/2024, 5:38 PMJemayn
11/26/2024, 6:57 PMtransformingIndexValues
event. This runs for every document that is indexed, so when a specific content node is indexed it runs this event and you can add additional fields and populate them with data.
The main points to remember is to make it as fast as possible to run and also to make it specific enough to not waste time on indexed documents that do not need the extra data.
I've written a blog where I show how to use this event to enrich the index with data from a separate content node which I get through Umbracos cache, but that could just as well be from an external data source:
https://dev.to/jemayn/index-pdfs-on-their-pages-in-umbraco-30l1
You should also beware that when you index data this way it is of course a snapshot, and refreshing the values happen when a page is published or when the index is fully rebuilt, so if your external data is something that fx is imported in a background job, then its a good idea to trigger an index rebuild after that job to ensure the newly imported values are updated in the index.Jemayn
11/26/2024, 7:05 PMcsharp
_examineManager.TryGetIndex(Umbraco.Cms.Core.Constants.UmbracoIndexes.ExternalIndexName, out IIndex index);
var results = index.Searcher.CreateQuery().NativeQuery(
$"__NodeTypeAlias: product " +
$"+((gln_da:{product.Gln} targetMarket_da:{product.TargetMarket} gtin_da:{product.Gtin}))").Execute();
if (!results.Any()) return;
var contentToReindex = new List<IContent>();
foreach (var searchResult in results)
{
// Reindex content
if (!int.TryParse(searchResult.Id, out int contentId))
continue;
var content = _contentService.GetById(contentId);
if (content is null) continue;
contentToReindex.Add(content);
}
index.IndexItems(_publishedContentValueSetBuilder.GetValueSets(contentToReindex.ToArray()));
Hooky
11/27/2024, 12:46 AMHooky
11/27/2024, 12:50 AMHooky
11/27/2024, 12:53 AMJemayn
11/27/2024, 11:59 AMJemayn
11/27/2024, 12:03 PMHooky
11/27/2024, 12:34 PMHooky
11/27/2024, 12:34 PM