neo4j/community — Issue #144: Index relationships of super nodes
Author: NielsHoogeveen
Created: 2011-12-22 21:01:41+00:00
State: open

I'd like to have a method of the form:

Node#getRelationship(Node, RelationshipType, Direction)

This method returns the relationships between two given nodes for a RelationshipType and Direction.

For regular nodes this can easily be done by checking all relationships of either the incoming or the outgoing node, but this is not an option when both sides of the relationship are super nodes.

Example:

Suppose I have a forum with potentially many users and potentially many posts/comments and I want to look up whether a user has read a certain post/comment.

To do so, I can create a relationship from user to post/comment of type READ, but no matter what, it will always take a lot of time to verify whether there is a relationship between two given nodes.

Of course, I can use an index-hack to do this, but I would prefer seeing this solved in the database core. Hence my request to lay out dense relationships as a btree (or similar datastructure) so the relationships to or from a certain node, given a direction and RelationshipType can quickly be found.

To support this, the Node interface would need methods like:

Node#getRelationship(Node, RelationshipType, Direction)
Node#getRelationship(Node, RelationshipType)
Node#getRelationship(Node, Direction)
Node#getRelationship(Node)