在ArangoDB中通过Edge-Attribut过滤顶点

时间:2015-12-08 13:25:45

标签: filter graph-databases arangodb aql nosql

我是ArangoDB的新手,并尝试做一个时空数据库。对于顶点“Parz1”,我连接了两个GeoJSON。我的目标是过滤几何体Vertex,其边缘的“Ende”键的值为“9999”。我在文档中找不到有关如何通过边缘值过滤顶点的内容。谢谢你的帮助!

第一个顶点:

  Document: Parzelle/Parz1
    _rev:83054176547
    _key:Parz1
    {
      "Nummer": "1",
      "Gmd": "Muttenz"
    }

几何体顶点:

    Document: Geometrie/Geom1
    _rev:83050703139
    _key:Geom1
    {
      "type": "Polygon",
      "coordinates": [
        [
          [
            600000,
            200000
          ],
          [
            600000,
            200002
          ],
          [
            600002,
            200002
          ],
          [
            600002,
            200000
          ],
          [
            600000,
            200000
          ]
        ]
      ]
    }
Document: Geometrie/Geom4
_rev:83051424035
_key:Geom4
{
  "type": "Polygon",
  "coordinates": [
    [
      [
        600000,
        200000
      ],
      [
        599998,
        200000
      ],
      [
        600000,
        200002
      ],
      [
        600002,
        200002
      ],
      [
        600002,
        200000
      ],
      [
        600000,
        200000
      ]
    ]
  ]
}

和边缘:

Edge: hatGeom/37050525987
_rev:83056470307
_key:37050525987
_from:Parzelle/Parz1
_to:Geometrie/Geom1
{
  "Start": "1950",
  "Ende": "2010"
}

Edge: hatGeom/37067237667
_rev:83056797987
_key:37067237667
_from:Parzelle/Parz1
_to:Geometrie/Geom4
{
  "Start": "2011",
  "Ende": "9999"
}

1 个答案:

答案 0 :(得分:1)

使用ArangoDB 2.8,我们提供了新的Traversal and pattern matching api;然后,您可以有效地按边和顶点进行过滤:

FOR v, e, p IN 
  1..3 OUTBOUND 'vertexCollection/startVertex'
  GRAPH 'geometryGraph' 
    FILTER p.edges[1].start > 1950 RETURN v

您甚至可能希望使用Geo index来查找图遍历的开始匹配项:

FOR startVertex IN WITHIN(vertexCollection, @latitude, @longitude, @limit) 
  FOR v, e, p IN 
    1..3 OUTBOUND startVertex
    GRAPH 'geometryGraph' 
      FILTER p.edges[1].start > 1950 RETURN v