Elasticsearch日期范围

时间:2016-11-09 18:05:23

标签: datetime elasticsearch

我有预订系统,可让您预订。

我想过滤所有预订的预订。

预订数据

开始|端

2015-10-01T03:00:00 | 2015-12-01T03:00:00

检查日期范围gtelte然后,使用范围方法非常容易

"range": {
    "startDate": {
        "gte": "2015-11-01T03:00:00"
    }
},
"range": {
    "endDate": {
        "lte": "2015-11-30T04:00:00"
    }
}

但是,在开始日期2015-11-01T03:00:00到结束日期2015-11-30T03:00:00之前,它不会得到已经开始的预订。

如何查看指定日期内的预订以及我日期之间的任何预订,以便我也可以过滤它们。

我在弹性搜索方面不是那么专家,但我创建了以下3个条件,需要在ealsticsearch中添加,我不知道如何添加它们。

$bookingStart = '2015-10-01T03:00:00';
$bookingEnd = '2015-12-01T03:00:00';

$currentStart = '2015-11-01T03:00:00';
$currentEnd = '2015-11-30T03:00:00';

// old booking that has started after our current time and ended before our current ending time
if ($bookingStart > $currentStart && $bookingEnd < $currentEnd)
;

// booking that started before our current time and ending after our current time
if ($bookingStart < $currentStart && $bookingEnd > $currentStart)
;

// old bookings that started later then our current booking, but ended after our current booking end time
if ($bookingStart > $currentStart and $bookingStart < $currentEnd and $bookingEnd > $currentEnd)
;

0 个答案:

没有答案