0

向 Neo4jClient 中已创建的关系索引添加关系的语法是什么?

我找到了以下帖子(在 neo4jclient 中添加与索引的关系),但它只说语法类似于节点的语法,但 CreateRelationship 方法没有支持向索引插入关系的签名。

对 Neo4jClient 菜鸟的任何帮助将不胜感激。

4

1 回答 1

1

您可以使用 ReIndex 命令执行此操作:

if(!GraphClient.CheckIndexExists("relatedto", IndexFor.Relationship))
    GraphClient.CreateIndex("relatedto", ExactIndex, IndexFor.Relationship);

var simple1 = new Simple {Value = "simple_1"};
var simple2 = new Simple { Value = "simple_2" };

var s1Ref = GraphClient.Create(simple1);
var s2Ref = GraphClient.Create(simple2);

var relationship = new RelatedTo(s2Ref){RelationshipValue = "indexed_" + s1Ref.Id};

var relRef = GraphClient.CreateRelationship(s1Ref, relationship);

//Adding to the index
GraphClient.ReIndex(relRef, new []{new IndexEntry("relatedto"){{"value", relationship.RelationshipValue}}});

Console.WriteLine("Use this in N4J Data Browser: rel:index:relatedto:value:{0}", relationship.RelationshipValue);
于 2013-08-15T09:24:54.000 回答