Try our conversational search powered by Generative AI!

Term facet with nested list

Vote:
 

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:

SearchClient.Instance
                .Search()
                .TermsFacetFor(x => x.Makes, x => x.Make)
                .GetResult();

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

#176889
Edited, Mar 29, 2017 10:58
Vote:
 

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

#176901
Mar 29, 2017 13:58
Vote:
 

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
.Search<SearchResultItem>()
.TermsFacetFor(x => x.Makes, x => x.Make)
.GetResult();

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

#176902
Edited, Mar 29, 2017 14:39
Vote:
 

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

#176907
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.