【问题标题】:gremlin query for the last element of multi property value of vertexgremlin 查询顶点多属性值的最后一个元素
【发布时间】:2016-10-26 13:00:05
【问题描述】:

我想使用具有元属性的多属性顶点对数据进行建模,例如:

多属性“日期”:[12/12/2012, 13/12/2012, 19/12/2012, 24/12/2012] 和每个日期值的元属性,例如,date: 12/12/2012 ("alimented" : "no")

如何查询顶点以获取为给定顶点插入的最后一个date 的值。在示例中,date: 24/12/2012 具有相应的元属性。

谢谢。

【问题讨论】:

    标签: gremlin tinkerpop datastax-enterprise-graph


    【解决方案1】:

    你可以使用order()步骤:

    gremlin> g = TinkerGraph.open().traversal()
    ==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
    gremlin> v = g.addV().next()
    ==>v[0]
    gremlin> v.property(list,'date',1, "alimented", "no")
    ==>vp[date->1]
    gremlin> v.property(list,'date',2, "alimented", "yes")
    ==>vp[date->2]
    gremlin> v.property(list,'date',3, "alimented", "no")
    ==>vp[date->3]
    gremlin> g.V(v).properties('date').order().by(value,decr).limit(1).valueMap(true)
    ==>[key:date, value:3, alimented:no, id:3]
    

    显然,您的“日期”字段必须是可以通过Comparable 排序的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-15
      • 1970-01-01
      • 2021-09-05
      • 1970-01-01
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多