Examine in Umbraco 10 vs Umbraco 9

Umbraco, Examine

Examine in Umbraco 10 vs Umbraco 9

Carl Rasmus Wriedt Bønnebæk
28 jun. 2022

I just had the pleasure of participating in a Umbraco training Session for Umbraco 9+ to upgrade my certification.

Today's course was Searching and Indexing with Umbraco Examine.

The course material was written for Umbraco 9, - but since Umbraco 10 is the new default, we might as well go for that one when creating new solutions. 

Going through the course went well besides a few minor issues i wasn't aware of.

  • Examine in Umbraco 10 is version 3, - and a few breaking changes have been introduced
  • The default Umbraco Package when you install UmbracoExamine.PDF is the v9 one.

 

Når du opretter en TransformingIndexValues handler

As for the first point, the breaking changes in Examine v3, - The only one i had the pleasure of running into was when trying to do a 

e.ValueSet.Add()

This method is no longer available, - and the short answer is that you have to use e.SetValues() with all the previous values, and of course the new ones you would like to add.

So the old code would look something like this

e.ValueSet.Add("contents", combinedFields.ToString());

where the new code would look like this.

 var updatedValues = e.ValueSet.Values.ToDictionary(x => x.Key, x => x.Value.ToList());

updatedValues.Add("contents", new List<object> { combinedFields.ToString() });

e.SetValues(updatedValues.ToDictionary(x => x.Key, x => (IEnumerable<object>)x.Value));

PS: The above solution is stolen from Patrick and Marcs great answers on our, that made my day today :)

Kom bare nærmere

Skal vi mødes og drikke en kop kaffe, eller tage et hurtigt teams møde, så sig til

Lokation

København / Amager

Telefon

Tlf: +45 60200656