使用Neo4jClient添加与索引的关系

时间:2013-08-15 07:53:10

标签: neo4jclient

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

我发现了以下帖子(Adding a relationship to an index in neo4jclient),但它只是说语法类似于节点,但CreateRelationship方法没有支持在索引中插入关系的签名。

非常感谢对Neo4jClient菜鸟的任何帮助。

1 个答案:

答案 0 :(得分: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);
相关问题