【问题标题】:How to get notifications that have Edge date property greater than last visited date in Titan using Gremlin?如何使用 Gremlin 在 Titan 中获取 Edge 日期属性大于上次访问日期的通知?
【发布时间】:2023-10-09 05:26:01
【问题描述】:

我的用户顶点具有传入通知边缘,如下所示:

用于获取通知的代码

g.v(17929472).outE('Notification')

我得到的回应:

{
  "success": true,
  "results": [
    {
      "Type": "UserReaction",
      "PostedDate": "2016-04-15T09:03:42.8391677Z",
      "NotificationInitiatedByVertexId": "2304",
      "_id": "c7bb4-aoagw-sgl-aoao0",
      "_type": "edge",
      "_outV": 17929472,
      "_inV": 17929728,
      "_label": "Notification"
    }
  ],
  "version": "2.5.0",
  "queryTime": 15.310751
}

每当用户查看通知时,我都会保存上次查看的日期并希望使用该日期来获取该日期之后出现的所有通知。

我试过了:

g.v((5124096).outE).outE.has('PostedDate',T.gte, 2016-04-15T07:52:31.6979843Z).inV

但它给出了错误。

【问题讨论】:

  • 您的代码表明您使用的是 TinkerPop 2.x。我强烈建议改用 TinkerPop 3+,它完全重写了一个更强大的 API。

标签: graph gremlin titan rexster


【解决方案1】:

PostedDate 似乎作为字符串返回。考虑将架构定义中的PostedDate 定义为Long,然后将T.gteLong 值进行比较。

【讨论】:

  • 我是否需要删除以前的测试数据,或者如果我只添加另一个属性作为 PostedDateLong 以及现有属性,它会起作用吗?
  • 去试试吧
  • 我添加了一条边,具有以下属性 类型:WallPostNotification PostedDate: 2016-04-15T15:01:21.1012501Z PostedDateLong: 635963292811012501 NotificationInitiatedByVertexId: 17928960 _id: c7lmo-1s0-sgl-aoetc 'PostedDateLong',T.gte, 0)
  • 但查询... g.E.has('PostedDateLong',T.gte, 0) 返回空集。