我处于对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”,“reason”:“[request] 数据太大,[]的数据会是 [622777920 / 593.9mb],大于极限 [622775500 / 593.9mb]“。这就是为什么我要申请一些限制让我 一次只能获得几百条记录。
有人可以指导我做错的地方吗?
答案 0 :(得分:0)
限制数据量以避免此错误的方法是配置indices.breaker.request.limit
。