简体   繁体   English

无法在 Neptune/Gremlin 中添加边缘属性?

[英]Unable to add edge properties in Neptune/Gremlin?

I've been trying to add edges to existing vertices and give them a specific ID and some properties using the Gremlin library in nodeJS (connecting to an AWS Neptune graph) However, even though it seems as if the edges are created, the ID and properties were completely missed.我一直在尝试向现有顶点添加边,并使用 nodeJS 中的 Gremlin 库(连接到 AWS Neptune 图)为它们提供特定的 ID 和一些属性但是,即使看起来好像创建了边,ID 和完全错过了属性。 Also I'll explain what I'm trying to achieve so the gremlin query will be clearer: Edges have 3 properties: Hidden, Directed, and ModificationDateTime.此外,我还将解释我要实现的目标,以便 gremlin 查询更加清晰:边具有 3 个属性:Hidden、Directed 和 ModificationDateTime。

  • look for an edge between pointA and pointB.寻找 pointA 和 pointB 之间的边。
  • if such an edge exists and its ModificationDateTime is greater than our given "ignoreIfAboveDateTime", don't do anything.如果存在这样的边缘并且它的 ModificationDateTime 大于我们给定的“ignoreIfAboveDateTime”,则不要做任何事情。
  • else if such an edge exists and ModificationDAteTime is lower) then update its properties.否则,如果存在这样的边缘并且 ModificationDAteTime 较低)则更新其属性。
  • else if it doesn't exist, create it with the given ID and add the properties.否则,如果它不存在,则使用给定的 ID 创建它并添加属性。

of course if there is a better way to do what I tried I would love to know and make it prettier!当然,如果有更好的方法来做我尝试过的事情,我很想知道并让它更漂亮!

I should mention that I am adding multiple edges with the same queries, meaning the following query is appended to itself (without the starting 'g') for each edge created.我应该提到我正在添加具有相同查询的多个边,这意味着对于创建的每个边,以下查询将附加到自身(没有起始“g”)。

` `

g
  .V(`${pointA}`) // find the vertex with the given ID
  .bothE(`${label}`) // find all edges with the given label
  .where(__.otherV().hasId(`${pointB}`)) // find the edge with the given label that point to the given vertex
  .fold()
  .coalesce(
    __.unfold().where(__.values('ModificationDateTime').is(gt(`${ignoreIfAboveDateTime}`))), // if there is an edge with the given label that points to the given vertex, and the edge's ModificationDateTime is greater than the given ignoreIfAboveDateTime, then do nothing
    __.coalesce(
      __.unfold(), // the edge exists, so it will only be updated
      __.V(`${pointA}`).addE(`${label}`).to(__.V(`${pointB}`)).property(id, `${id}`) // the edge doesn't exist, so it will be created
    )
      .property('Hidden', `${hidden}`)
      .property('Directed', `${directed}`)
      .property('ModificationDateTime', `${modificationDateTime}`)
  )

` `

When getting the edges the results are (for a single edge): { id:'82c27123-b690-296d-2266-24f377334c13' inV: v[056a3511-45ca-4e7c-838c-b144598ae0e54294967296] label: 'EdgesTestLabel123' outV: v[87fc214b-7066-460e-8660-c0ef19344a6b4294967296] properties: {} }当获取边缘时,结果是(对于单个边缘): { id:'82c27123-b690-296d-2266-24f377334c13' inV: v[056a3511-45ca-4e7c-838c-b144598ae0e54294967296] label: 'EdgesTestLabel123' outV: v[87fc214b-7066-460e-8660-c0ef19344a6b4294967296] properties: {} }

Will appreciate any tip regarding this, thanks: :)将不胜感激有关此的任何提示,谢谢::)

I made a stupid我做了个蠢货

It works just fine, I just assumed that the "properties" returned are the actual properties of the edge but they weren't.它工作得很好,我只是假设返回的“属性”是边缘的实际属性,但事实并非如此。 when I got the edges with valueMap() everything was there, oh well当我用 valueMap() 得到边缘时,一切都在那里,哦,好吧

暂无
暂无

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

相关问题 在添加或更新边缘时出现错误“未匿名生成 - 使用 __ class 而不是 TraversalSource”(在 Neptune 中使用 gremlin) - Getting Error "not spawned anonymously - use the __ class rather than a TraversalSource " while adding or updating the edge(in Neptune using gremlin) 我如何对 Gremlin/Neptune 进行条件排序 - How can I do conditional sort on Gremlin/Neptune Neptune,Python,Gremlin:使用值数组更新图形顶点中的属性 - Neptune, Python, Gremlin: Update a property in a graph vertex with an array of values 无法为 Neptune 集群配置参数组 - Unable to configure Parameter Group for Neptune Cluster AWS Neptune 无法加载单一基数 - AWS Neptune unable to load with Single cardinality 在 IPython Notebook 中的 AWS Neptune ML 中检索或存储 Gremlin 查询的结果 - Retrieve or store results of Gremlin queries within AWS Neptune ML, in IPython Notebook Gremlin:AWS Neptune - 获取图中每个节点的所有叶节点作为 CSV - Gremlin : AWS Neptune - Get all Leaf Nodes for each Node in the Graph as CSV 缺少参数 - 无法将 CSV 从 s3 加载到海王星 - Missing parameters - unable to load CSV from s3 to neptune gremlin.net 如何使用 id 创建顶点/边 - gremlin.net how to create vertex/edge with id java.io.InvalidClassException:org.apache.tinkerpop.gremlin.hadoop.structure.HadoopConfiguration; 无法创建实例 - java.io.InvalidClassException: org.apache.tinkerpop.gremlin.hadoop.structure.HadoopConfiguration; unable to create instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM