【发布时间】: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","reason":"[request] 数据太大,[] 的数据将是 [622777920/593.9mb],大于限制 [622775500/593.9mb]"。这就是为什么我想应用一些限制,以便我 一次只能获取几百条记录。
谁能指导我哪里做错了?
【问题讨论】:
标签: elasticsearch elasticsearch-rails elasticsearch-model