简体   繁体   English

向 Datastax CassandraCSharpDriver.Graph 中的现有顶点添加新顶点和边,但出现边输出错误

[英]Adding a new vertex and an edge to an existing vertex in Datastax CassandraCSharpDriver.Graph but get edge OUT error

I'm adding a new vertex and an edge to an existing vertex in Datastax Graph, and I wanted to see how to do that with Datastax CassandraCSharpDriver.Graph.我正在向 Datastax Graph 中的现有顶点添加一个新顶点和一条边,我想看看如何使用 Datastax CassandraCSharpDriver.Graph 做到这一点。

The working Gremlin code looks like this:工作 Gremlin 代码如下所示:

Vertex link1 = graph.addVertex(label, "link").property("id", "link-2")
Vertex item1 = g.V().has("item", "id", "item-1").next()
item1.addEdge('contains', link1)

But in the C# driver syntax, I was hoping to do something like this but when I execute it, the error is the "adjacency of 'contains' in direction 'OUT' has not been added to 'link'"但是在 C# 驱动程序语法中,我希望做这样的事情,但是当我执行它时,错误是“方向 'OUT' 中的 'contains' 邻接尚未添加到 'link'”

GraphTraversalSource g = DseGraph.Traversal(mySession);
var traversal = g.AddV("link").Property("id", "link-1")
                .AddE("contains")
                .V("item").Has("id", Eq("item-1"));
GraphResultSet result = mySession.ExecuteGraph(traversal);

I had created the edge and edge connections like this:我创建了这样的边缘和边缘连接:

schema.edgeLabel("contains").multiple().create()  
schema.edgeLabel("contains")  
.connection("item", "link")  
.connection("link", "item")  
.add()  

Any ideas if the schema edge is setup incorrectly or how to do this the best way in Datastax CassandraCSharpDriver.Graph?如果架构边缘设置不正确,或者如何在 Datastax CassandraCSharpDriver.Graph 中以最佳方式执行此操作有任何想法吗?

Your Gremlin here:你的小精灵在这里:

g.AddV("link").Property("id", "link-1")
            .AddE("contains")
            .V("item").Has("id", Eq("item-1")

isn't properly formed.没有正确形成。 It should be:它应该是:

g.AddV("link").Property("id", "link-1").As('l1').
  V("item").Has("id", Eq("item-1")).
  AddE('contains').To('l1')

With AddE() you need to specify the From() and the To() to identify the vertices that the edge is connecting.使用AddE()您需要指定From()To()以标识边连接的顶点。 Without specifying those, AddE() will just use the incoming Vertex for both values creating a self-referencing edge.如果不指定这些, AddE()将只使用传入的Vertex来创建自引用边的两个值。 As a result in this case, you should only need to specify the To() as the From() is inferred.因此,在这种情况下,您应该只需要指定To()作为推断的From()

Please note the examples in the Reference Documentation where you should see other methods to doing this.请注意参考文档中的示例,您应该在其中看到执行此操作的其他方法。

暂无
暂无

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

相关问题 使用 C# Datastax CassandraCSharpDriver.Graph 获取连接到已知顶点的所有未知顶点 - Get all unknown vertices connected to a known vertex with C# Datastax CassandraCSharpDriver.Graph Select 一个顶点,如果边到顶点有一个属性值,否则选择另一个具有不同边属性值的顶点 - Select a vertex if the edge to the vertex has a property value, otherwise choose another vertex with a different edge property value 在C#中创建非常大的边线和顶点图 - Create very large edge and vertex graphs in C# gremlin.net 如何使用 id 创建顶点/边 - gremlin.net how to create vertex/edge with id Gremlin查询Cosmos Graph DB以获取围绕单个顶点的图结构,过滤出具有特定标签的节点 - Gremlin query for Cosmos Graph DB to get the graph structure surrounding a single vertex, filtering out nodes with specific labels 在 CassandraCSharpDriver.Graph 中使用 SimpleGraphStatement 的树查询抛出“无法转换为 org.apache.tinkerpop.gremlin.structure.Element” - Tree query using SimpleGraphStatement in CassandraCSharpDriver.Graph throws “cannot cast to org.apache.tinkerpop.gremlin.structure.Element” Gremlin cosmos:如何在重复命令中将边缘的属性值复制为顶点属性 - Gremlin cosmos: How to copy a property value of edge as vertex property inside a repeat command 确定多边形的哪个边正好位于已处理顶点的上方。 从上到下对边缘进行排序 - Determine what edge of polygon is lying immediately above processed vertex. Sort edges top to bottom gameObject超出屏幕边缘 - gameObject out of screen edge 获取IoT边缘设备的现有子设备列表 - Get list of existing child device of IoT edge device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM