Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

TotalMatching for FilterHits in UnifiedSearch

Vote:
 

Hi,

 

We are using UnifiedSearch in our solution and giving facets for SearchSection:

var q = SearchClient.Instance.UnifiedSearchFor(request.Query).TermsFacetFor(p => p.SearchSection);

    

Also there is a "filter" option to drill into specific search section:

if (!string.IsNullOrEmpty(request.Term))
{
    q = q.FilterHits(sc => sc.SearchSection.Match(request.Term));
}

    

SearchSection facet is used as list of filters showing also total matching hits for that facet. The issue is for results.TotalMatching property. We have to show also "Show all (x)" facet together with totally matched hits. If user is not using filtering TotalMatching property contains number of hits for that particular query - which is fine and I can use this number showing "Show all" filter. When we need to filter by search section, facets returned as result contains correct number of matching hits, however I still need to render "Show All (x)" link that will show how much *was* TotalMatching hits for the query without filter.

What is the best practice to get this number? At the moment I'm caching from the search without any filter.

Thanks!

#75152
Sep 18, 2013 16:23
Vote:
 

Hi Valdis,

 

You can use FilterFacet for this. For an example see this link and look for the line ".FilterFacet("AllSections", x => ".

#75246
Sep 23, 2013 15:02
Vote:
 

Great success. Sometimes it's hard to find the answer :)

#75293
Sep 24, 2013 12:59
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.