Search code examples
neo4jneo4jclient

Adding a relationship to an index in neo4jclient


This might be real newbie question but please bear with me as I am new. I looked at this code sample in documentation.

 graphClient
    .Cypher
    .Start(new {
        n1 = "custom",
        n2 = nodeRef,
        n3 = Node.ByIndexLookup("indexName", "property", "value"),
        n4 = Node.ByIndexQuery("indexName", "query"),
        r1 = relRef,
        moreRels = new[] { relRef, relRef2 },
        r2 = Relationship.ByIndexLookup("indexName", "property", "value"),
        r3 = Relationship.ByIndexQuery("indexName", "query"),
        all = All.Nodes
    });

In the example above I would like to get a relationship by IndexLookup. So I created a Relationship Index

 _graphClient.CreateIndex("item_relationship_idx", new IndexConfiguration
            {
                Provider = IndexProvider.lucene,
                Type = IndexType.exact
            },
                 IndexFor.Relationship);

Question - How do I get a relationship created by _graphClient.CreateRelationship into an index. Most of the samples provided just show getting NodeReference into an Index. I am sure I am missing something obvious. Any help would be appreciated.


Solution

  • Update to Neo4jClient 1.0.0.568 or above and you'll find the (new) support for relationship indexing, consistent with how node indexing works.

    (You should also look at Neo4j 2.0 and try and use the new indexing infrastructure though. No point writing new code against old approaches.)