From a7ff32891ed87bb724fa02d41232ffcec474e499 Mon Sep 17 00:00:00 2001 From: Elitsa Date: Mon, 8 Jul 2024 09:28:34 +0300 Subject: [PATCH] Making sure base.OnTransformingIndexValues(e); is called for DeliveryApiContentIndex without the special index value transformations --- .../UmbracoExamineIndex.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs index 5faccf581f..fb162b6521 100644 --- a/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs +++ b/src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs @@ -115,16 +115,32 @@ public abstract class UmbracoExamineIndex : LuceneIndex, IUmbracoIndex, IIndexDi { base.OnTransformingIndexValues(e); + // Performs special value transformations to all deriving indexes of this base class + // but the DeliveryApiContentIndex (they are not needed in this case). + // The alternative is to move the call to ApplySpecialIndexValueTransformations into a new base class + // that all implementors but the DeliveryApiContentIndex would inherit from but that would be breaking + // for any custom indexes deriving from UmbracoExamineIndex. + if (e.Index.Name != Constants.UmbracoIndexes.DeliveryApiContentIndexName) + { + ApplySpecialIndexValueTransformations(e); + } + } + + /// + /// Updates the index ValueSet with a special __Path and __Icon fields. + /// + private void ApplySpecialIndexValueTransformations(IndexingItemEventArgs e) + { var updatedValues = e.ValueSet.Values.ToDictionary(x => x.Key, x => (IEnumerable)x.Value); - //ensure special __Path field + // Ensure special __Path field var path = e.ValueSet.GetValue("path"); if (path != null) { updatedValues[UmbracoExamineFieldNames.IndexPathFieldName] = path.Yield(); } - //icon + // Ensure special __Icon field if (e.ValueSet.Values.TryGetValue("icon", out IReadOnlyList? icon) && e.ValueSet.Values.ContainsKey(UmbracoExamineFieldNames.IconFieldName) == false) {