I've really been struggling with getting this to work. Would really appreciate any help with this. Basically I have a time_period field that contain an array of two unix timestamps:
time_period: [1660410000000, 1660842000000]
I'm doing a a range query with two timestamps:
range: {
time_period: {
gte: <timestamp>,
lte: <timestamp>
}
}
basically I want to get any record where the time_period timestamps overlap in any way with the gte and lte timestamps. It works great EXCEPT for when the gte and lte are WITHIN the time_period range. Then I get nothing.
I figured the default "intersects" relation would work like this, but it doesn't. Any idea what I'm missing or doing wrong?
Thanks in advance for any help!
CodePudding user response:
I would use a date_range
field type which is meant for this type of use.
You should map time_period
like this:
...
"time_period": {
"type": "date_range"
}
...
Then your document would contain this:
"time_period": {
"gte": 1660410000000,
"lte": 1660842000000
}
And your range
query would work out of the box.