【问题标题】:ElasticSearch apply limit on bucket resultsElasticSearch 对存储桶结果应用限制
【发布时间】:2018-10-08 02:12:17
【问题描述】:

我处于对 ElasticSearch 应用限制的情况 结果,但它对我不起作用。我已经通过ES guide 下面是我的代码:

module Invoices
    class RestaurantBuilder < Base
      def query(options = {})
        buckets = {}
        aggregations = {
          orders_count: { sum: { field: :orders_count } },
          orders_tip: { sum: { field: :orders_tip } },
          orders_tax: { sum: { field: :orders_tax } },
          monthly_fee: { sum: { field: :monthly_fee } },
          gateway_fee: { sum: { field: :gateway_fee } },
          service_fee: { sum: { field: :service_fee } },
          total_due: { sum: { field: :total_due } },
          total: { sum: { field: :total } }
        }

        buckets_for_restaurant_invoices buckets, aggregations, options[:restaurant_id]

        filters = []
        filters << time_filter(options)

        query = {
          query: { bool: { filter: filters } },
          aggregations: buckets,
          from: 0,
          size: 5
        }
        query
      end

      def buckets_for_restaurant_invoices(buckets, aggregations, restaurant_id)
        restaurant_ids(restaurant_id).each do |id|  
          buckets[id] = {
            filter: { term: { restaurant_id: id } },
            aggregations: aggregations
          }
        end
      end

      def restaurant_ids(restaurant_id)
        if restaurant_id
          [restaurant_id]
        else
          ::Restaurant.all.pluck :id
        end
      end
    end
end

restaurant_ids 函数返回大约 5.5k 家餐厅,所以在这个 如果我收到一个错误 "circuit_breaking_exception","re​​ason":"[request] 数据太大,[] 的数据将是 [622777920/593.9mb],大于限制 [622775500/593.9mb]"。这就是为什么我想应用一些限制,以便我 一次只能获取几百条记录。

谁能指导我哪里做错了?

【问题讨论】:

    标签: elasticsearch elasticsearch-rails elasticsearch-model


    【解决方案1】:

    限制数据量避免这个错误的方法是配置indices.breaker.request.limit

    【讨论】:

    • 有没有办法限制记录数?我不知道应该把 indices.breaker.request.limit 放在哪里??
    猜你喜欢
    • 2017-01-09
    • 2011-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-21
    • 2019-04-23
    • 1970-01-01
    • 2020-03-19
    相关资源
    最近更新 更多