简体   繁体   English

Cosmos DB Gremlin“项目”未产生预期结果

[英]Cosmos DB Gremlin “project” not producing expected results

I have the following traversal that shows that the selected Vertex has 14 Edges labeled "follows". 我的以下遍历表明所选的顶点有14条标记为“跟随”的边。

 g.V().has('user','email','me@email.com').project('name','email','follow-edges').by('name').by('email').by(outE().hasLabel('follows').project('id','inV').by('id').by('inV'))

Which produces the following results: 产生以下结果:

[{
"name": "David",
"email": "me@email.com",
"follow-edges": 14}]

But when I want to project the "follows" Edge's id and inV ids, I'm only getting one result item back. 但是,当我要投影 “跟随” Edge的ID和inV ID时,我只能得到一个结果项。

g.V().has('user','email','david@me.com').project('name','email','follow-edges').by('name').by('email').by(outE().hasLabel('follows').project('edge-id', 'inV-id').by('id').by('inV'))

Results: 结果:

[{
"name": "David",
"email": "me@email.com",
"follow-edges": {
  "edge-id": "ccc06183-f4ca-410d-9c3c-9d2dfd93f5f0",
  "inV-id": "f4703a07-f42d-46f9-86be-7f5440f07f12"
}}]

I was expecting to get a list of all the "follows" edge's for the selected vertex. 我期望获得所选顶点的所有“跟随”边的列表。 Similiar to the answer given by Stephen Mallette at this link . 类似于Stephen Mallette在此链接上给出的答案。

Does anyone know why this is not working? 有谁知道为什么这不起作用?

You need to reduce the stream of objects in your anonymous traversal in by() - note my addition of fold() : 您需要在by()减少匿名遍历中的对象流-请注意我对fold()

g.V().has('user','email','david@me.com').
  project('name','email','followedges').
    by('name').
    by('email').
    by(outE().hasLabel('follows').
       project('edge-id', 'inV-id').
         by('id').
         by('inV').fold())

I assume that "inV" is an actual property and you're not trying to get the "in vertex" of the edge. 我假设“ inV”是一个实际属性,并且您并不是要获取边缘的“顶点”。 If you are trying to get the "in vertex" then you need by(inV().id()) . 如果要获取“顶点”,则需要by(inV().id())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM