文档

在线查询算子

更新时间:

Source算子

GraphStep,支持点,例如

g.V()
g.V(id1, id2)
g.E()

Filter算子

HasStep,支持所有的has过滤,例如

g.V().has("attrName")
g.V().has("attrName", attrValue)
g.V().has("attrName", gt(1))

IsStep,支持所有的is过滤,例如

g.V().values("age").is(gt(70))

TraversalFilterStep,支持所有的filter过滤,例如

g.V().filter(values("age").is(gt(20)))

WherePredicateStep,支持所有的where过滤,例如

g.V().where(out().count().is(gt(4)))

DedupGlobalStep,支持所有的dedup计算,例如

g.V().out().dedup()
g.V().out().dedup().by("name")

RangeGlobalStep,支持所有的range计算,例如

g.V().out().limit(100)
g.V().out().range(10, 20)

SimplePathStep,支持simplePath计算,例如

g.V().repeat(out().simplePath()).times(3).valeus("name")

Filter扩展支持

  • 正则匹配: 在has/filter/where中支持字符串的正则匹配,语法为Text.match(key, regexValue)或者Text.match(regexValue)

g.V().has("name", Text.match("*j*"))
g.V().values("name").filter(Text.match("*j*"))
  • 字符串的包含计算:在has/filter/where中支持字符串的包含等匹配计算,语法为Text.contains/Text.startsWith/Text.endsWith

g.V().has("name", Text.startsWith("To"))
g.V().values("name").filter(Text.startsWith("To"))

说明: 在字符串的包含计算如(startsWith/endsWith/contains)中,还支持not计算,例如:查找名字不是以To开头的点

g.V().has("name", P.not(Text.startsWith("To")))

  • 列表的包含计算:在has/filter/where中支持列表的包含、包含任意、包含所有等计算,语法为Lists.contains/Lists.containsAny/Lists.containsAll,例如:存在一个a属性为int列表

g.V().has("a", Lists.contains(30))
g.V().values("a").filter(Lists.containsAny(Lists.of(10, 20, 30))

说明: 列表的包含计算如(contains/containsAny/containsAll),同时还支持not计算,例如查找属性a的值中不包含30的点

g.V().has("a", P.not(Lists.contains(30)))

Map算子

ConstantStep,支持输出常量

g.V().out().contant(1)
g.V().out().constant("aaa")

CountLocalStep,支持list/map的local count计算

g.V().out().values("age").fold().count(local)

DedupLocalStep,支持list数据去重

g.V().out().fold().dedup(local).by("name")

EdgeOtherVertexStep,支持otherV计算

g.V().bothE().otherV()

IdStep,支持输出id

g.V().id()

LabelStep,支持输出label

g.V().label()

OrderLocalStep,支持List的本地排序

g.V().out().fold().order().by("name")

PropertyKeyStep,输出属性的key数据

g.V().properties("name").key()

PropertyValueStep,输出属性的value数据

g.V().properties("name").value()

RangeLocalStep,输出列表指定的子列表数据

g.V().out().fold().order(local).by("name").range(local, 2, 4)

SelectOneStep,输出指定的as的标签数据

g.V().as("a").out().out().select("a")

SelectStep,输出多个指定的as的标签数据

g.V().as("a").as("b").out("c").out().select("a", "b", "c")

PathStep,支持输出path数据

g.V().out().in().path()
g.V().outE().inV().path().bay("name").by("weight").by("name")

FlatMap算子

VertexStep,出、入点计算,例如out/in/both等

g.V().out()
g.V().in('person_knows_person')

EdgeVertexStep,支持边的inV/outV等计算,例如

g.V().outE('person_knows_person').inV()
g.V().inE().bothV()

PropertiesStep,支持输出属性计算,例如

g.V().values()
g.V().values("name", "age")
g.V().valueMap()

BranchStep,支持branch-option计算,支持int/long/string/none/any作为option值,例如

g.V().branch(values("name")).option("tom", out()).option("lop", in()).option(none, valueMap())
g.V().branch(out.count()).option(0L, valueMap()).option(1L, out()).option(any, in())

UnfoldStep,将列表/map中的数据打散输出,例如

g.V().group().by().by(values("name")).select(values).unfold()

Aggregate算子

CountGlobalStep,计算count值,例如

g.V().out().count()
g.V().where(out().in().count().is(0))

FoldStep,将数据聚合成列表,例如

g.V().fold()
g.V().values("name").fold()

GroupCountStep,按照指定的key计算count,例如

g.V().out().groupCount()
g.V().values("name").groupCount()

GroupStep,按照指定的key和值进行聚合,例如

g.V().out().group()
g.V().out().group().by("name")
g.V().out().group().by().by("name")

MaxGlobalStep,计算全局的最大值,例如

g.V().values("age").max()

MinGlobalStep,计算全局最小值

g.V().values("age").min()

SumGlobalStep,计算全局的和

g.V().values("age").sum()

Repeat循环算子

支持times计算

g.V().repeat(out()).times(4).valueMap()

支持until计算

g.V().repeat(out()).until(out().count().is(eq(0))).valueMap()

支持emit计算

g.V().emit().repeat(out()).times(4).valueMap()
  • 本页导读 (0)
文档反馈