Hi,
I have a problem, and a solution. But maybe there is a better solution.
My problem:
I need to make a query with a date range {"lt": "2019-W04", "gte": "2019-W03"}
The date field has xxxx-'W'ww
as date format.
But the result of this query is a document with 2019-W04
as date.
The epoch timestamp in this document is 1548028800000
so 2019-01-21, the first day of the week 4 of 2019, cool.
But when I did an explain with this query, on the found document, it used this range: [1547683200000 TO 1548287999999]
, so from 2019-01-17
(thursday of the week 3) to 2019-01-23
(wednesday of the week 4).
Question:
Why the range filter use the middle of the week to make the query ?
My solution:
Round date values with ||/w
{"lt": "2019-W04||/w", "gte": "2019-W03||/w"}
Range from explain: [1547424000000 TO 1548028799999]
, so from 2019-01-14
(monday of the week 3) to 2019-01-20
(sunday of the week 3), youhou
Do you have a better solution ?