【问题标题】:Searchkick: including some where clauses in smart_aggsSearchkick:在 smart_aggs 中包含一些 where 子句
【发布时间】:2020-10-27 12:03:43
【问题描述】:

使用aggs 时如何使用某些过滤器而不使用其他过滤器?如果我使用smart_aggs: false,则aggs 计数中没有使用过滤器。

默认情况下,条件适用于聚合。

Product.search "wingtips", where: {color: "brandy"}, aggs: [:size]
# aggregations for brandy wingtips are returned

更改为:

Product.search "wingtips", where: {color: "brandy"}, aggs: [:size], smart_aggs: false
# aggregations for all wingtips are returned

需要在某些地方允许收入,但在其他地方不允许收入

Product.search "wingtips", where_no_aggs_count: {country_availability: "us"}, where_aggs_count: {color: "brandy"}, aggs: [:size], smart_aggs: false

【问题讨论】:

    标签: ruby-on-rails elasticsearch ruby-on-rails-6 searchkick


    【解决方案1】:

    查询和聚合在 Elasticsearch 中链接。 如果您需要 2 个不同的上下文,则必须执行 2 个不同的请求。

    【讨论】:

      猜你喜欢
      • 2013-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-06
      相关资源
      最近更新 更多