Reputation: 2149
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!
Upvotes: 0
Views: 462
Reputation: 59793
There is no wildcard search in MongoDB.
You'd need to store the Node
s somehow flattened to perform that query. You could for example store the hierarchy (the parent chain) in each Node
so that you could recreate the hierarchy with your client application code.
The most commonly used structures are very well documented here.
Upvotes: 1