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

Try our conversational search powered by Generative AI!

Terms Facet wrong count when Filter is used

Vote:
 

Hi!

I am working with Epi Find on an Epi 6 R2 site and I'm having an issue with terms facets.

My problem is that the Count property of TermsFacet objects show the total amount of this facet BEFORE filters.

Example:

var result = SearchClient.Instance.UnifiedSearchFor("foo");
                 .FilterHits(x => x.SearchTitle.MatchCaseInsensitive("testpage"));

                 .TermsFacetFor(x => x.SearchTypeName)

                 .GetResult();

var typeFacets = result.TermsFacetFor(x => x.SearchTypeName);

The typeFacets Count property here wont take into acount the filtering with FilterHits, meaning if I take away that row the counts for the typeFacets objects will still be the same.

So if the total hits for "foo" is 100, but after filtering on "testpage" only has 1 result, a facet for SearchTypeName might still have Count 90.

Any ideas?






#80494
Jan 23, 2014 15:35
Vote:
 

use .Filter() instead of .FilterHits().

FilterHits will only filter the result, not the facets.

#80497
Jan 23, 2014 16:15
Vote:
 

That did the trick. Perfect! Thanks a lot.

#80498
Jan 23, 2014 16:23
Vote:
 

Is their anyway I can just update the count value for the Facet, I do not want to filter them out ?

#192926
May 23, 2018 18:52
Vote:
 

Hi Minesh, did you find a solution to your issue?  I have a similar issue whereby I want to use FilterHits to get all of the facets but with an updated count.  Thanks for your help!

#221875
Apr 27, 2020 14:55
Minesh Shah (Netcel) - Apr 27, 2020 17:40
I cant remember exactly what I was trying to achieve in 2018, are you able to give more context on what your issue is.

If you want to return all Terms even with 0 results you can use the AllTerms feature

.TermsFacetForCategory(f => f.Category, facet =>
{
facet.Size = 100;
facet.AllTerms = query.AllTerms;
})
Vote:
 

Hi Daniel, Please try with this query.

.UnifiedSearchFor("foo").For("testpage").Include(x => x.SearchText.AnyWordBeginsWith("testpage"));

#221909
Edited, Apr 28, 2020 2:32
* 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.