November Happy Hour will be moved to Thursday December 5th.

Exception: mapping for explicit nested path is not mapped as nested

Vote:
 

Hi,

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:

"AvailablePrices": [

        {

            "CustomerPricing": {

                "$type": "Mediachase.Commerce.Pricing.CustomerPricing, Mediachase.Commerce",

                "___types": [

                    "Mediachase.Commerce.Pricing.CustomerPricing",

                    "System.Object",

                    "System.IEquatable`1[[Mediachase.Commerce.Pricing.CustomerPricing, Mediachase.Commerce, Version=10.8.0.0, Culture=neutral, PublicKeyToken=6e58b501b34abce3]]"

               ]

            },

            "___types": [

                "EPiServer.Commerce.SpecializedProperties.Price",

                "System.Object",

                "System.ICloneable"

            ],

            "ValidFrom$$date": "2013-12-05T23:00:00Z",

            "$type": "EPiServer.Commerce.SpecializedProperties.Price, EPiServer.Business.Commerce",

            "UnitPrice": {

                "Amount$$number": 210,

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! 

/Mark

#188657
Feb 28, 2018 15:21
Vote:
 

Hi Mark, 

I am experiencing the same issue. 
Where you able to sort it out? 

Thanks!

#194219
Jun 15, 2018 22:28
Vote:
 

Hi Mauro,

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)
{
    base.ApplyConventions(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.

/Mark

#194296
Jun 19, 2018 9:46
Vote:
 

Thanks Mark, 

It weren't those assemblies the ones I had missing, but your answer pointed out where to look at.

I had this one missing:

  • Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.22.0.0

Adding that NuGet package solved it.

Thanks again,

Mauro.

#194360
Jun 19, 2018 15:55
Vote:
 

Good to hear it helped! 

#194361
Jun 19, 2018 15:56
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.