Gremlin-通过属性的属性搜索顶点

时间:2019-02-21 21:28:05

标签: gremlin

我有一个在特定属性下具有嵌套属性的顶点。示例:

  {
    "id": "X",
    "label": "deployment",
    "type": "vertex",
    "properties": {
      "name": [
        {
          "id": "X",
          "value": "myvalue1"
        }
      ],
      "labels": [
        {
          "id": "xxxxx",
          "value": "my-labels",
          "properties": {
            "key": "value"
          }
        }
      ]
    }
  }

我的问题是:我想搜索具有特定值的子属性。我将如何构造查询以查找具有该值的顶点?我似乎找不到任何有关尝试找到该子属性的文档。

有关查找和排序顶点属性的大量文档,但并非如此。

这样做的目的是在我的标签下有许多“标签”,并且我最终希望在具有匹配子标签的顶点之间创建边。

1 个答案:

答案 0 :(得分:0)

这将是对所有顶点的扫描,因此请注意,它不会成为高性能查询。

g.V().filter(properties("my-labels").has("key", "value"))

The Crew图提供示例:

//
// Where did TinkerPop crew members move in and after 2005?
//
gremlin> g = TinkerFactory.createTheCrew().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:14], standard]
gremlin> g.V().filter(properties("location").has("startTime", gte(2005))).
           project("name","locations").
             by("name").
             by(properties("location").has("startTime", gte(2005)).value().fold())
==>[name:marko,locations:[santa fe]]
==>[name:stephen,locations:[purcellville]]
==>[name:matthias,locations:[baltimore,oakland,seattle]]
==>[name:daniel,locations:[kaiserslautern,aachen]]
相关问题