1

I'm using the .NET Client to query Episerver Find, I'm filtering the results on an ancestor Page Id to search within sub-sections of the site and this works fine:

var result = _searchClient.Search<ProductPageData>()
                          .For(query)
                          .Filter(x => x.Ancestors().Match(sectionPageLink.ID.ToString()))
                          .GetContentResult();

Now I want to add some facet navigation so I'm using HistogramFacetFor and TermsFacetFor but the counts in the facet counts don't appear to be respecting the Filter operations:

var result = _searchClient.Search<ProductPageData>()
                          .For(query)
                          .HistogramFacetFor(x => x.Price, PriceInterval)
                          .TermsFacetFor(x => x.Brand)
                          .Filter(x => x.Ancestors().Match(rootPageLink.ID.ToString()))
                          .GetContentResult();

Results in the following numbers:

result.TotalMatching = 11

Brand:
    Brand 1 : 5 items
    Brand 2 : 6 items
    Brand 3 : 3 items
      Total = 14

Price:
      0 - 100 : 2
    101 - 200 : 5
    201 - 300 : 7
        Total = 14

Without the filter the TotalMatching is 14, so it appears Facets don't respect the Filter(), is this correct or am I doing something wrong?

Greg B
  • 14,597
  • 18
  • 87
  • 141

1 Answers1

0

Have you tried moving the Filter above the facets? Filters should affect facets, unless you're using FilterHits instead of just Filter.

Johan Petersson
  • 972
  • 4
  • 13
  • Yes, I've tried it both ways and it returns the same result regardless. I'm using `Filter(...)` as in my code sample above. Is this documented anywhere, I can't see anything on Episerver World that talks specifically about the combination of Filtering and Facets. – Greg B Jan 12 '17 at 13:16
  • http://world.episerver.com/documentation/developer-guides/find/NET-Client-API/searching/Filtering/Filter-and-FilterHits/ – Johan Petersson Jan 12 '17 at 15:12