Hierarchical notion a core part: Yes and no :-) Consider a class
class HierarchyMember()
{
string Name { get; set; }
string Hierarchy { get; set; }
HierarchyId Node { get; set; }
}
Instances of this would be stored as normal documents in RavenDB, but Node is of a type that would work similarly to SQL Server 2008 HierarchyId (therefore I just called it HierarchyId, although I doubt that the SQL Server version can be used..), and represent a position in a tree hierarchy. A string representation of the contents of this field would be
/1/ - top node in the tree
/1/1/ - first child node
/1/2/ - second child node
/1/2/1/ - first child of second child node
The binary representation of this Type in SQL Server is supposed to be very efficient, so huge trees can be represented in a compact way. However, as I see it, the most important point is to allow efficient indexing of such members,
//Depth first
Map = hierarchyMembers =>
from member in hierarchyMembers
select new { Hierarchy = member.Hierarchy, Node = member.Node }
//Breadth first
Map = hierarchyMembers => from member in hierarchyMembers
select new { Hierarchy = member.Hierarchy, Level = member.Hierarchy.GetLevel(), Node = member.Node }
in order to allow the following queries:
hierarchyMembers.Hierarchy = "1" && hierarchyMembers.Node.IsDescendantOf( "/1/2/" ) // return all children
hierarchyMembers.Hierarchy = "1" && hierarchyMembers.Node.IsDescendantOf( "/1/2/" ) && hierarchyMembers.Level == 3 // return direct children
One would also need clever functions to create a new node "between" to existing ones, and to "reparent" a subtree (both are covered by SQL 2008 HierarchyId). Reparenting could easily run on the parent, and a PATCH would update the documents.
So, the indexed member would have to by hierarchical by nature, and would need client and server implementations, but documents and everything else don't need any structural changes to RavenDB, the way I see it. It would be a fantastic addition. It would allow me to store "right-sized" documents in RavenDB, and at the same time efficiently manage the documents in a hierarchy (multiple hierarchies for that matter, by definining multiple HierarchyId-members).
Hope I'm not wasting your time.
Cheers