Updating Examine index outside of node publishing,...
# help-with-umbraco
i
I'll try and explain. We have the concept of a "Device" being stored as nodes in Umbraco. For each device we have a number of custom fields being added to the Examine Index in a IndexProviderTransformingIndexValues event. This is working ok. What we would like to do, is add other custom fields against a device i.e Last Log Updated or Last Calibration Date and update these fields when the data "outside" of the node is changed. The data is stored in a custom database table in the same instance as Umbraco with the link being the Device node Key. Yes we could do a SQL lookup from the table, but for performance I want all the data in Examine for retrieval later. Now, I realise that if someone publishes a Device, then these custom fields may get removed or altered (as they dont exist on the Device), and I'll try to handle that, but is there a way to get a record from Examine, update a field, and push it back into Examine, without Publishing the Device node and/or using the IndexProviderTransformingIndexValues?? i.e combo of ValueSetBuilder & IndexPopulator maybe?
j
Within your IndexProviderTransformingIndexValues event you can fetch the external data and add the fields you want. This means when a page is published it will again fetch the data and update all fields including your own. Only other usecase you need to cover is then if you want to refresh your index document without touching the corresponding content node, and for that you can fetch the index from the examineManager and make a call to reindex specific content documents:
Copy code
csharp
_examineManager.TryGetIndex(Umbraco.Cms.Core.Constants.UmbracoIndexes.ExternalIndexName, out IIndex index);

        index.IndexItems(_publishedContentValueSetBuilder.GetValueSets(contentToReindex.ToArray()));
6 Views