Skip to content

Commit

Permalink
Making sure base.OnTransformingIndexValues(e); is called for Delivery…
Browse files Browse the repository at this point in the history
…ApiContentIndex without the special index value transformations
  • Loading branch information
elit0451 committed Jul 8, 2024
1 parent f6deaca commit a7ff328
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Umbraco.Examine.Lucene/UmbracoExamineIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,32 @@ protected override void OnTransformingIndexValues(IndexingItemEventArgs e)
{
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);
}
}

/// <summary>
/// Updates the index ValueSet with a special __Path and __Icon fields.
/// </summary>
private void ApplySpecialIndexValueTransformations(IndexingItemEventArgs e)
{
var updatedValues = e.ValueSet.Values.ToDictionary(x => x.Key, x => (IEnumerable<object>)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<object>? icon) &&
e.ValueSet.Values.ContainsKey(UmbracoExamineFieldNames.IconFieldName) == false)
{
Expand Down

0 comments on commit a7ff328

Please sign in to comment.