RavenDb - 递归查询/索引,层次文档 [英] RavenDb - Recursive queries/indexes, for Hierarchical Document

查看:260
本文介绍了RavenDb - 递归查询/索引,层次文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能有点一个愚蠢的问题,可能是做
错了,但我会问什么办法。

I know this might be a bit of a silly question, probably doing it wrong but I'll ask any way.

可以说我有一组分层的文件。
它们包含有关其层次结构中的
座的唯一信息是他们的父母的ID。如果其空我们到达山顶。

Lets say I have a set of Hierarchical Documents. The only information they contain about their place in the hierarchy is their parent id. If its null we have reached the top.

获取父母和孩子是容易的部分。

Getting parents and children are the easy part.

我想要做的是所有的后代和祖先查询。
我想我有部分这个问题。
1)为了得到祖先的文件是他们没有办法让一个
递归查询?获取父父父,直到为空。

What I want to do is query for all the descendants and ancestors. I think I have to parts to this question. 1) To get the ancestors to a document is their any way to make a recursive query? Get the parent parent until parent is null.

2)是他们的任何方法,使指数/推算,我们可以在
祖先ID映射到一个文件中。然后查询祖先ID或
文件ID?因为如果我能得到这个索引它会很容易地说
获得文档ID等于
documentid我想从得到孩子们通过祖先ID的所有文件。

2) Is their any way to make a index/projections where we can map the ancestor ids to a document. And then query the ancestor id or the document id? Because if I could get that index it would be easy to say get all documents by ancestor id for document id equal to the documentid i want to get the children from.

比方说我有这样的结构。

Lets say I have this structure.

文件1结果
文档1.1结果
文件1.1.1结果
文件1.1.2

文档1.2结果
文件1.2.1

Document 1
Document 1.1
Document 1.1.1
Document 1.1.2
Document 1.2
Document 1.2.1

我要寻找的财产以后这样的指数

I want a index looking somthing like this

DocumentID结果
1.1结果
1.1.1结果
1.1.1结果
1.1.2结果
1.1.2结果
1.2结果
1.2.1结果
1.2.1

DocumentID
1.1
1.1.1
1.1.1
1.1.2
1.1.2
1.2
1.2.1
1.2.1

AncestorID
1分配结果
1结果
1.1结果
1结果
1.1结果
1结果
1.2

AncestorID 1
1
1.1
1
1.1
1
1.2

推荐答案

这是详细RavenDB邮件列表上讨论:的 https://groups.google.com/d/topic/ravendb/ptBYL9A5PA8/discussion

This was discussed in detail on the RavenDB mailing list: https://groups.google.com/d/topic/ravendb/ptBYL9A5PA8/discussion

选择的解决方案,我相信,将涉及全面祖先每个文档中

The chosen solution, I believe, involved putting the full ancestry in each document.

这篇关于RavenDb - 递归查询/索引,层次文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆