【发布时间】:2018-10-18 09:45:36
【问题描述】:
我是ElasticSearch的新手,想知道是否可以根据restaurant_id显示数据,然后是确认订单的平均时间。例如,我有文件:
{ _index: "orders-development",
_type: "order",
_id: "4412917",
_score: 1,
_source: {confirm_duration: 5}
}
{ _index: "orders-development",
_type: "order",
_id: "4412917",
_score: 1,
_source: {confirm_duration: 4}
}
{ _index: "orders-development",
_type: "order",
_id: "4322923",
_score: 1,
_source: { confirm_duration: 12}
}
以上是存储在ES中的文件,现在我要根据restaurant_id显示数据,然后是平均时间。所以现在我使用下面的代码并显示错误 "reason":"[terms] unknown field [avg], parser not found"
aggregations = {
avg_order_confirmation: {
terms: {
field: :restaurant_id,
size: 100,
avg: { field: :confirm_duration },
}
}
}
【问题讨论】:
标签: ruby-on-rails elasticsearch elasticsearch-rails elasticsearch-model