Gremlinepipeline 两个顶点之间的边

Gremlinepipeline Edges between two Vertex

要在 java 代码中使用 Gremline 管道检查顶点之间的边缘? 我能够创建边,但如果我们再次给出相同的顶点,将创建新边。我想在 2 个顶点之间创建一条独特的边。 有什么帮助吗? 我正在使用 orientDB

您可以在 Edge class 上创建一个唯一索引,这将为您提供该约束

create class Foo extends V
create class FooEdge extends E
create property FooEdge.in LINK
create property FooEdge.out LINK

create index FooEdge_in_out on FooEdge (out,in) unique
insert into Foo set name = 'Foo1'
insert into Foo set name = 'Foo2'
create edge FooEdge from (select from Foo where name = 'Foo1') to (select from Foo where name = 'Foo2')
/* fail */
create edge FooEdge from (select from Foo where name = 'Foo1') to (select from Foo where name = 'Foo2')