1

I'm using Sitecore 9.3 and Solr 8.1.1. I'm developing a search filter using Sitecore Content Search API, with the behavior of keeping the facet count the same even after selecting options.

For example, if the filter have these options :

  • Option 1 , count = 11
  • Option 2 , count = 20
  • Option 3 , count = 8

If I select Option 1, other options' count will change according to this selection.

I don't want that, I want to maintain the count as it is in the same Solr query. At the same time, I have multiple filters, so I want to keep the count for only the options in the selected filter, while other filters count can be changed.

2
  • Looks like you need to separate Solr call for facets count and skip filters while getting facets count
    – Marek Musielak
    Apr 8, 2022 at 9:07
  • @MarekMusielak I agree with you, but I have multiple filters, and I need to keep the count for only the options in the selected one. Apr 8, 2022 at 9:41

1 Answer 1

0

Solr provides Tagging and Excluding Filters functionality to support facets for multi-select fields. It allows to tag a part of filter query and then exclude the tagged part when counting facets for a specific field.

Sitecore Content Search provider currently does not support tag and ex parameters and does not have any Linq extension methods for passing them to Solr.

There is a good example of how to prepare and apply these parameters by extending Sitecore Content Search query with SolrNet QueryOptions in the question Sitecore Solr multiple filter tagging / excluding.

However, if you want to solve this by using only out-of-the-box Content Search API, be prepared to perform N+1 requests to Solr (where N is the number of multi-select filters with at least one option selected):

  1. Request with all filters applied to get valid results.
  2. Request without conditions from the first multi-select filter to get facets for this filter options.
  3. Request without conditions from the second multi-select filter, and so on until you process all multi-select filters.
1
  • Thank you a lot, this is really helpful Apr 12, 2022 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.