0

I have a Java/mongo object Node that can contain another Node, etc. So my structure in mongo is:

like Document->Node->Node->...

A Node has a name attribute, and I want to find all Documents that have a node (including any nested Nodes) that contains a certain name.

I was using dot notation to do something like:

query.field("document.node.name").equal(name)

but that only works if the parent node has a matching name.. what I need is some kind of wildcard to search for any name (document.node.node....name etc) that is in a Node object.

Thanks for the help!

4

1 回答 1

1

MongoDB 中没有通配符搜索。

您需要以Node某种方式将 s 存储起来以执行该查询。例如,您可以在每个中存储层次结构(父链),Node以便您可以使用客户端应用程序代码重新创建层次结构。

最常用的结构在此处有很好的记录。

于 2013-11-14T00:50:05.027 回答