Gremlin 針對日期的properties進行過濾

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進行正確過濾,結果如下:
在這裏插入圖片描述

發佈了12 篇原創文章 · 獲贊 6 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章