print("Hello everybody1")
对于我的硕士,我有1门编程课程,这是第一次开设该课程,因此会导致很多问题。我们对Elasticsearch的理解是有限的。对于作业,我有一个文件,其中包含按工作日排序的订单的旅行时间。目前,我遇到以下两个问题:
searchbody_total_hours ={
"size": 0,
"aggs":{
"time_per_hour_per_day_of_week": {
"terms": {
"size": 24,
"script":{
"lang": "painless",
"source": "doc['datetime_of_order'].value.dayOfWeek"
}
},
"aggs": {
"number_of_weeks": {
"date_histogram": {
"field": "datetime_of_order",
"interval": "week"
}
},
"aggs": {
"totaltime": {
"sum": {
"field": "travel_time"
}
},
"average_travel_time": {
"bucket_script": {
"buckets_path": {
"totaltime": "travel_time",
"number_of_weeks": "number_of_weeks._bucket_count"
},
"script": "params.totaltime / params.number_of_weeks"
}
}
}
}
}
}
}
searchbody_total_orders = {
"query":{
"bool": {
"must":{
"match": {"weekdayName" : "Monday"}
}
}
},
"aggs": {
"total_orders_per_hour_per_week_of_day": {
"terms":{
"size": 15,
"script": {
"lang": "painless",
"source": "doc['datetime_of_order'].value.hourOfDay"
}
},
"aggs": {
"number_of_weeks":{
"date_histogram":{
"field": "datetime_of_order",
"interval": "week"
}
},
"average_orders_per_hour_per_day_of_week": {
"bucket_script":{
"buckets_path": {
"doc_count": "_count",
"number_of_weeks": "number_of_weeks._bucket_count",
},
"script": "params.doc_count / params.number_of_weeks"
}
}
}
}
}
}
如果有人可以通过某些方法来改进我的代码或拥有更多信息的链接,我将不胜感激。
亲切的问候
科恩