Try our conversational search powered by Generative AI!

Term facet with nested list


Hello, we have a problem with getting facet from list of nested objects.

We need to store list of nested objects and retrieve unique values for them. It seems that TermsFacetFor function is perfect for this purpose.

According to the documentation I've added nested convension in my initialization module:

SearchClient.Instance.Conventions.NestedConventions.ForType().Add(x => x.Makes);

I made index rebuild and after that I tried to retrieve term using following code:

                .TermsFacetFor(x => x.Makes, x => x.Make)

But term facet does`t contain any values, through index contains some values.
We use Episerver.Find, this feature should work for this version. We believe that we missed something so any help will be appreciated.

Edited, Mar 29, 2017 10:58

Try using .ForInstancesOf<> instead of ForType<> (and the reindex). How do you retrieve the facets?

Mar 29, 2017 13:58

We tried it with .ForInstancesOf<>, but result is still empty

SearchClient.Instance.Conventions.NestedConventions.ForInstancesOf<SearchResultItem>().Add(x => x.Makes);

We are retrieving facets with following code:

var facet = SearchClient.Instance
.TermsFacetFor(x => x.Makes, x => x.Make)

return facet.TermsFacetFor(x => x.Makes, x => x.Make).Select(x => x.Term);

Edited, Mar 29, 2017 14:39

I don't see why your code should not work. Is "Makes" the actual property name, or just an example? If it's an extension method, you'll have to remember to include it via conventions

Mar 29, 2017 15:54
* 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.