orientdb

OrientDB图遍历教程有哪些

小樊
82
2024-10-29 17:42:19
栏目: 编程语言

OrientDB图遍历主要通过两种查询语言实现:TRAVERSEMATCH。这两种语言都提供了丰富的函数来满足不同的遍历需求。

TRAVERSE语法格式

TRAVERSE [class.]field | * | any() | all()
FROM <target>
[MAXDEPTH <number>] | [WHILE <condition>]
[LIMIT <max-records>]
[STRATEGY <strategy>]

MATCH语法格式

MATCH { [class: <class>], [as: <alias>], [where: (<whereCondition>)] }
.<functionName>(){ [class: <classname>], [as: <alias>], [where: (<whereCondition>)], [while: (<whileCondition>)], [maxDepth: <number>], [depthAlias: <identifier>], [pathAlias: <identifier>], [optional: (true | false)] }*
RETURN <expression> [AS <alias>] [, [AS]]*
GROUP BY <expression> [, <expression>]*
ORDER BY <expression> [, <expression>]*
SKIP <number>
LIMIT <number>

示例代码

TRAVERSE out('EdgeClass') FROM (SELECT * FROM Profiles WHERE id = 1)
LIMIT 8
MATCH { [class: Profiles], [as: p], [where: (id = 1)] }
.-outE('EdgeClass')-> { [class: Profiles], [as: p2], [where: (id = 2)] }
RETURN p2.id, p2.name

最佳实践

通过上述教程和示例,您可以更好地理解和应用OrientDB的图遍历功能。

0
看了该问题的人还看了