Hi there, I have a complex situation.
Let me define my context. I am working on a project related to YouTube videos. I have data of videos. A typical document looks like.
{
"_index": "tubecvideos",
"_type": "_doc",
"_id": "9-zawF84CLY",
"_score": 1.0,
"_source": {
"id": "9-zawF84CLY",
"kind": "youtube#video",
"etag": """"8jEFfXBrqiSrcF6Ee7MQuz8XuAM/b_o-VL3-2N-fUDZuvli2rtGgzcc"""",
"is_indexed": false,
"is_indexed_1": true,
"old_statistics": [
{
"viewCount": "388763",
"likeCount": "1294",
"dislikeCount": "780",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-27 00:41:15.382"
},
{
"viewCount": "389750",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-28 09:44:44.793"
},
{
"viewCount": "389874",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-28 12:47:28.898"
},
{
"viewCount": "390304",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-29 00:42:07.387"
},
{
"viewCount": "390660",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-29 12:26:49.124"
},
{
"viewCount": "391103",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-30 00:41:43.295"
},
{
"viewCount": "391425",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-30 12:15:37.771"
},
{
"viewCount": "391833",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-30 23:11:56.981"
},
{
"viewCount": "391863",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-31 00:26:13.405"
},
{
"viewCount": "392189",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-08-31 12:18:28.994"
},
{
"viewCount": "392633",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-09-01 00:03:46.909"
},
{
"viewCount": "392975",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-09-01 12:14:04.153"
},
{
"viewCount": "393414",
"likeCount": "1295",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-09-02 00:12:13.958"
}
],
"month_diff": {
"viewCount": 7624,
"likeCount": 7,
"dislikeCount": 2,
"favoriteCount": 0,
"commentCount": 0,
"time": "2019-08-23 09:59:36.80",
"hours_diff": 552
},
"publishedAt": "2018-10-20T07:00:00.000Z",
"channelId": "UC4NALVCmcmL5ntpV0thoH6w",
"title": "Two Little Dickie Birds - THE BEST Educational Songs for Children | LooLoo Kids",
"channelTitle": "LooLoo Kids - Nursery Rhymes and Children's Songs",
"defaultAudioLanguage": "en",
"viewCount": "394513",
"likeCount": "1297",
"dislikeCount": "782",
"favoriteCount": "0",
"commentCount": "51",
"time": "2019-09-03 12:24:24.610"
}
},
I want to get the video who has the most views gained between two dates like I have to tell my audience that Video "X" has gained most views in the last week. I have that data of views after every 12 hours as you can see from old_statisctics but I can't find a query to find a difference and sort by that.