Azure cosmosdb 调用属性后如何返回顶点
设置完url后,我想返回顶点添加更多属性,我该怎么做Azure cosmosdb 调用属性后如何返回顶点,azure-cosmosdb,gremlin,Azure Cosmosdb,Gremlin,设置完url后,我想返回顶点添加更多属性,我该怎么做 g.addV('Site') .property(list, 'name', 'stackoverflow') .properties('name') .hasValue('stackoverflow') .property('url', 'https://stackoverflow.com') 编辑:找到了如何使用gremlin实现这一点,但它在cosmosdb上不起作用 g.addV('Site') .property(list, 'n
g.addV('Site')
.property(list, 'name', 'stackoverflow')
.properties('name')
.hasValue('stackoverflow')
.property('url', 'https://stackoverflow.com')
编辑:找到了如何使用gremlin实现这一点,但它在cosmosdb上不起作用
g.addV('Site')
.property(list, 'name', 'stackoverflow')
.properties('name')
.hasValue('stackoverflow')
.property('url', 'https://stackoverflow.com')
.next()
.element()
有人知道在cosmosdb上实现同样目的的其他方法吗?从某种意义上说,你实际上不能使用
next()
,因为next()
正在迭代遍历,返回一个结果,因此此时你就离开了Gremlin的API。除非将Graph
实例嵌入到同一JVM中,否则从next()
返回的Graph元素将被“分离”,因此是不可变的
也就是说,值得注意的是,通过调用property(list,'name','stackoverflow')
实际上并没有将顶点
遍历器留在后面,因此您可以直接在它后面调用字符串property()
:
g.addV('Site').
property(list, 'name', 'stackoverflow').
property('url', 'https://stackoverflow.com')
现在,如果我从字面上理解你的小精灵,你在那里做的是创建一个“name”属性,然后找到该属性并向其添加元属性“url”,然后询问如何返回原始父顶点,因为此时你实际上返回了一个VertexProperty
。首先请注意,您可以更直接地设置元属性,避免调用properties()
:
g.addV('Site').
property(list, 'name', 'stackoverflow', 'url', 'http://stackoverflow.com')
实际上,在某种意义上,您不能使用
next()
,因为next()
正在迭代遍历,并返回一个结果,因此此时您将离开Gremlin的API。除非将Graph
实例嵌入到同一JVM中,否则从next()
返回的Graph元素将被“分离”,因此是不可变的
也就是说,值得注意的是,通过调用property(list,'name','stackoverflow')
实际上并没有将顶点
遍历器留在后面,因此您可以直接在它后面调用字符串property()
:
g.addV('Site').
property(list, 'name', 'stackoverflow').
property('url', 'https://stackoverflow.com')
现在,如果我从字面上理解你的小精灵,你在那里做的是创建一个“name”属性,然后找到该属性并向其添加元属性“url”,然后询问如何返回原始父顶点,因为此时你实际上返回了一个VertexProperty
。首先请注意,您可以更直接地设置元属性,避免调用properties()
:
g.addV('Site').
property(list, 'name', 'stackoverflow', 'url', 'http://stackoverflow.com')