Try our conversational search powered by Generative AI!

Unified search - using category filters and facets

Vote:
 

I am trying to understand how to implement filters and facets for categories with a unified search.

I have tried specifying and accessing the ISearchContent.SearchCategories propeties like this:

var query = SearchClient.Instance.UnifiedSearchFor('query');

// Add facets
query.TermsFacetFor(x => x.SearchCategories);

// Get results
var results = query.GetResult();

// Get category facets for results
var facets = results.TermsFacetFor(x=> x.SearchCategories);

When I try to get the facets into variable 'facets', a null reference exeption is thorwn.

I kind of expect this as I don't understand how Finds will know how to collate categories across the pages, blocks and files from the unified search.

Is it possible to-do this with a unified search? Are there any examples?

Adam

 

  

 

 

#72368
Jun 14, 2013 11:53
Vote:
 

You have to chain 'query':

query = query.TermsFacetFor(x => x.SearchCategories)

as it won't be added to the current object and therefore it is not requested when you execute the query.

#72377
Edited, Jun 14, 2013 13:03
Vote:
 

Thanks Henrick - that makes sense.

 

How do I make sure that categories for files in the VPP are held in the SearchCategories property? 

 

#72399
Jun 14, 2013 16:33
Vote:
 

Create an extension named 'SearchCategories' (important as it is matched by name) returning a list of strings and register it as index:

SearchClient.Conventions.ForInstancesOf<UnifiedFile>()
.IncludeField(x => x.SearchCategories())

#72400
Jun 14, 2013 16:49
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.