Gremlin date properties filter 針對日期的properties進行過濾
Gremlin date properties filter
針對gremlin語法中如果需要針對日期的properties進行過濾
案例
如果一個圖中的邊有個屬性time,是date類型。然後給定一個時間範圍,需要過濾出時間範圍內的邊
gremlin語法
g.E().has('time',between('2020-01-19 00:00:00','2020-01-20 00:00:00'))).values('time')
輸入上面的語法的話會報錯:
Value [2020/01/19 00:00:00] is not an instance of the expected data type for property key [time] and cannot be converted. Expected: class java.util.Date, found: class java.lang.String
因此需要將上面的日期類型從string轉爲date
正確的gremlin語法如下
g.E().has('time',between(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse('2020-01-19 00:00:00'),new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse('2020-01-20 00:00:00'))).values('time')
輸入上面的語法可以針對時間類型的properties進行正確過濾,結果如下: