Facets on nested classes

Vote:
 

Hi,

we custom indexing our Commerce catalog.  The items that we need to build facets on are in the nested classes.

e.g.

public GameProduct

{

    public List varients;

} 

public GameVarient

{

 public List Countries;

public int Genre;

}

The search indexes the GameProduct and we would like to build facets based on the Genre in the GameVarient class.

It seems that this is not possible to do in EPiServer Find although its possible in Elastic Search?

A solution would be to roll up the Genre to the top level class, but unfortunately we perform filtering on the countries.

Any help or feedback would be appreciated.

Thanks

#116219
Jan 26, 2015 18:00
Vote:
 

First of all your products and variants should inherit from ProductContent and VariantContent. Then all fields you want to be indexed add as properties (not fields). Use "get" only properties for fields which are "calculated" - in your case Variants in GameProduct. The result should look like:

public class GameProduct : ProductContent {
    public List<GameVariant> Variants {
        get {
            var loader = ServiceLocator.Current.GetInstance<IContentLoader>();
            return this.GetVariantRelations()
                 .Select(relation => loader.Get<VariationContent>(relation.Target))
                 .ToList();
        }
    }
}

public class GameVariant : VariationContent {
    public int Genre { get; set; }
}

Now EPiServer Find should be able to index Variants property of GameProduct.

But I would suggest you better to search variants, not products. Then you can build Genre facets and do filtering on countries. If you need product, you can get matching one for variant.

#116357
Jan 29, 2015 8:56
Vote:
 

Hi,

I've written a gist with TermsFacet-extensions that supports nested objects: https://gist.github.com/lindstromhenrik/30391262cf166a07f451

/Henrik

#116751
Feb 04, 2015 13:53
Vote:
 

Hi all,

Maris, I agree.  The sample here is a simplified version and we need to be able to build facets on nested properties.

 

Thanks Henrik, it work perfectly!

#116862
Feb 06, 2015 12:24
Vote:
 

Daniel,

Were you able to build facets on the List Countries of the nested class? Did you end up making your own solution for it?

#180812
Jul 26, 2017 18:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.