开发者

Solr - retrieving facet counts for unfiltered version of query

开发者 https://www.devze.com 2023-01-02 14:38 出处:网络
I\'m using Solr for searching, and recently started using faceting to allow users to nar开发者_运维技巧row their search.However, once the user filters by one of the facets, the other filter options ar

I'm using Solr for searching, and recently started using faceting to allow users to nar开发者_运维技巧row their search. However, once the user filters by one of the facets, the other filter options are no longer returned in the facet results. This is expected, but not what I'd like.

Is there some way to return the facet fields and counts for the unfiltered query, without doing an extra search? For instance, if the user filters by category (by selecting a specific category), I'd like them to still be able to pick one of the other categories without having to explicitly remove the filter first. (That is, all of the categories—and their counts—should still be returned by Solr, so that I can include them on the page along with the filtered query set.)

I suspect this may not be possible. If it isn't I can just do an extra query per search, which would leave out the filter (and return 0 rows), as described in a previous StackOverflow question. But I thought I'd ask: does anyone know a way to do this without multiple queries?


This is called multi-select faceting and it is possible using specific LocalParams to exclude filters when faceting. See "Tagging and excluding Filters" for details.


This is a SO answer also explaining this but with an example provided:

SolrNet : Keep Facet count when filtering query,

and here is a fresh SOLR documentation URL, since URLs from both this and linked SO answers are outdated now:

https://solr.apache.org/guide/8_11/faceting.html#tagging-and-excluding-filters

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号