简体   繁体   English

Gremlin Value Map 带边阵列

[英]Gremlin Value Map With Array of Edges

I am trying to query a vertex with Node Gremlin and AWS Neptune for its properties and get all vertices connected to it by an 'out' edge and all of their properties as well in a single output.我正在尝试使用 Node Gremlin 和 AWS Neptune 查询顶点的属性,并在单个 output 中通过“出”边缘及其所有属性获取所有顶点。 For instance, if I have a 'Baker' vertex with an edge 'bakes' to two 'Cake' vertices, I want to get a 'Baker' object with all his properties as well as an array on him of the two 'Cake' vertices as objects with all their properties.例如,如果我有一个“贝克”顶点,其边“烘烤”到两个“蛋糕”顶点,我想得到一个“贝克”object,其中包含他的所有属性以及两个“蛋糕”的数组顶点作为具有所有属性的对象。

I know I can effectively do this with a.project but I do not want to have to select for specific properties for any vertices because I want all of their properties.我知道我可以使用 a.project 有效地做到这一点,但我不想 select 用于任何顶点的特定属性,因为我想要它们的所有属性。

I am currently working with a query like this: gV(BakerId).as('Baker').out('bakes').as('Cake').select('Baker','Cake').by(valueMap(true)) , but the problem with this is that this query gives me a list of two outputs, one with the Baker and the first Cake and another with the same Baker and the second cake.我目前正在处理这样的查询: gV(BakerId).as('Baker').out('bakes').as('Cake').select('Baker','Cake').by(valueMap(true)) ,但问题是这个查询给了我一个包含两个输出的列表,一个带有 Baker 和第一个 Cake,另一个带有相同的 Baker 和第二个蛋糕。 I want to avoid the redundancy and have it consolidated in a single output with the Baker appearing just once.我想避免冗余并将其合并到一个 output 中,而 Baker 只出现一次。

I also am hoping for a solution versatile enough (or simple enough to easily extend) to handle going yet a level deeper to do the same with 'out' edges on the 'Cake' vertices eg 'Cake' --> 'madeOf' --> 'Ingredient' so I can get a single Baker with each Cake on it just once each with each Ingredient on them just once each, and all with all their properties as well.我也希望有一个足够通用的解决方案(或足够简单以轻松扩展)来处理更深层次的问题,以便在“蛋糕”顶点上的“外”边上做同样的事情,例如“蛋糕”->“制造”- ->“成分”,所以我可以得到一个面包师,每个蛋糕上只有一次,每个成分上只有一次,并且都具有所有属性。

You can use two project steps and use valueMap so you won't need to sespecifiy the properties:您可以使用两个project步骤并使用valueMap ,这样您就不需要 sespecifiy 属性:

g.V().hasLabel('Baker').
  project('Baker', 'Cake').
    by(valueMap(true)).
    by(out('bakes').
      project('Cake', 'Ingredients').
        by(valueMap(true)).
        by(out('madeOf').valueMap(true).
          fold()).fold())

example: https://gremlify.com/34e9o3r9gag例如: https://gremlify.com/34e9o3r9gag

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

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