Solr - 检索查询的未过滤版本的方面计数
我使用 Solr 进行搜索,最近开始使用分面来允许用户缩小搜索范围。但是,一旦用户按其中一个方面进行筛选,其他筛选选项将不再在方面结果中返回。这是预料之中的,但不是我想要的。
有没有某种方法可以返回未过滤查询的构面字段和计数,而无需进行额外的搜索?例如,如果用户按类别过滤(通过选择特定类别),我希望他们仍然能够选择其他类别之一,而不必先显式删除过滤器。 (也就是说,所有类别及其计数仍应由 Solr 返回,以便我可以将它们与过滤后的查询集一起包含在页面上。)
我怀疑这可能是不可能的。如果不是,我可以为每个搜索执行一个额外的查询,这将忽略过滤器(并返回 0 行),如 之前的一个 StackOverflow 问题。但我想我会问:有谁知道一种无需多次查询即可做到这一点的方法吗?
I'm using Solr for searching, and recently started using faceting to allow users to narrow 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这称为多选分面,并且可以在分面时使用特定的 LocalParams 排除过滤器。有关详细信息,请参阅“标记和排除过滤器”。
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.
这是一个SO答案,也解释了这一点,但提供了一个示例:
SolrNet:Keep Facet过滤查询时进行计数,
这是一个新的 SOLR 文档 URL,因为来自此和链接 SO 答案的 URL 现在都已过时:
https://solr.apache.org/guide/8_11/faceting.html#tagging-and-execution-filters
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