I’m having difficulties getting a nested value into my Find index.I have a Commerce Variant with a property that exposes an IEnumerable:
public IEnumerable AvailablePrices => this.Prices();
where this.Prices() is the default IPricingExtensions method. (I’ve also tried using Prices() directly but getting the same error)
In the conventions I have:SearchClient.Instance.Conventions.NestedConventions.ForInstancesOf().Add(x => x.AvailablePrices);
This gets indexed fine:
"$type": "Mediachase.Commerce.Pricing.CustomerPricing, Mediachase.Commerce",
"System.IEquatable`1[[Mediachase.Commerce.Pricing.CustomerPricing, Mediachase.Commerce, Version=10.8.0.0, Culture=neutral, PublicKeyToken=6e58b501b34abce3]]"
"$type": "EPiServer.Commerce.SpecializedProperties.Price, EPiServer.Business.Commerce",
Still, when querying I get:
nested: ElasticSearchIllegalArgumentException[mapping for explicit nested path is not mapped as nested: [AvailablePrices]];
this is called in:
query = query.OrderBy(v => v.AvailablePrices, p => p.UnitPrice.Amount, price => price.ValidFrom.LessThan(DateTime.Now) & (price.ValidUntil.Exists() | price.ValidUntil.GreaterThan(DateTime.Now)) & (price.MarketId.Value.Match("BBNL")));
Episerver Find version: 12.5
Hope anyone can help!
I am experiencing the same issue. Where you able to sort it out?
Yes, I did with the help of Episerver support. It turns out some packages where missing from my solution. The exception that you see here is a bit misleading. There was another exception:
TL/DR: some packages that where referenced where not loaded and this caused another exception.Details:ERROR EPiServer.Find.Commerce.FindCommerceInitializationModule: Could not apply catalog content conventions.System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.This one is thrown when calling:
public override void ApplyConventions(IClientConventions clientConventions)
When decompiling Episerver we get this:
protected virtual void ApplyNestedConventions(NestedConventions nestedConventions)
nestedConventions.ForInstancesOf<IPricing>().Add<Price>((Expression<Func<IPricing,IEnumerable<Price>>>) (pricing => pricing.Prices()));
nestedConventions.ForInstancesOf<IIndexedPrices>().Add<Price>((Expression<Func<IIndexedPrices,IEnumerable<Price>>>) (pricing => pricing.Prices()));
nestedConventions.ForInstancesOf<IStockPlacement>().Add<Inventory>((Expression<Func<IStockPlacement,IEnumerable<Inventory>>>) (stockPlacement => stockPlacement.Inventories()));
It turns out that this piece of code refenced some packages that where not found:• Microsoft.Data.Edm 5.6.4• Microsoft.Data.OData 5.6.4• Microsoft.Data.Services.Client 5.6.4• System.Spatial 5.6.4
After succesfully adding these packages it works. I have to add that we where in the process of updating to EPi 11 and this caused a dll hell where we had different versions of packages in our solution!
Hope this helps.
It weren't those assemblies the ones I had missing, but your answer pointed out where to look at.
I had this one missing:
Adding that NuGet package solved it.
Good to hear it helped!