Questions about TermsFacetFor and AllTerms

Vote:
 

Does TermsFacetFor return the facet count as in an un-filtered search although a filter is applied?

On my site, I have two facets: PropertyA and PropertyB. Say, that I have two pages on my site. The first page has the following values:

PropertyA = 1

PropertyB = 2

The second page has

PropertyA = 4

PropertyB = 5

If I filter my results on PropertyA==1, like:

search.Filter(x => x.PropertyA.In([1]))

and I apply TermsFacetFor() for both PropertyA and PropertyB during my search, one should think that my facets in the search result would hold only TermCounts for the values of PropertyB that are among the search results, that is, 2. But when I run the tests, TermsCounts are returned for both 2 and 5 in the facet for PropertyB.

Is that correct behaviour?

Will AllTerms=true always return facets for all languages?

I have a site that is available in Danish and English. When I set AllTerms=true inside TermsFacetFor, it seems that the list of TermsFacet objects holds TermCounts for all facet values in both Danish and English, although I have specified the search to be within one language, fx. I set

search.FilterForVisitor("en")

Say, that I invoke TermsFacetFor to get facets for my property PropertyC. This is a culture-specific property, so the value of PropertyC can be "XXX" in English and "YYY" in Danish on the same page. When I apply TermsFacetFor with AllTerms = true in my search, I get a TermCount object for both "XXX" and "YYY".

Is that correct behaviour or am I missing something?

Thanks!

#209718
Edited, Nov 19, 2019 21:34
Vote:
 

Regarding the first question: I found that a bug in the frontend led me to thinking that the count was not updated, when a filter was applied to the search. This was not the case - the count is actually updated, so the answer to the first question is "no".

The second question still applies :)

#209737
Nov 19, 2019 21:33
Vote:
 

Hi Esben, 

I think your assumption about AllTerms is correct yes. Episerver Find is built on top of Elastic Search - so the AllTerms property equates to the all_terms parameter used in Elastic Search. 

If you take a look here:

https://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-facets-terms-facet.html

You'll see the description of the parameter - "Allow to get all the terms in the terms facet, ones that do not match a hit, will have a count of 0. Note, this should not be used with fields that have many terms."

If you just want to get all terms facets unfiltered you could make use of the FilterHits method : https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Filtering/Filter-and-FilterHits/

Thanks,

Paul

#210541
Nov 27, 2019 11:12