我一直在阅读tutorial on Modelling Tree Structures with Materialized Paths:
本教程包含使用父路径查找子项的查询。但我的问题是如何在java中进行查询。
我尝试使用以下代码实现此目的:
BasicDBObject query = new BasicDBObject();
query .put("Path", java.util.regex.Pattern.compile("/,Programing,/"));
DBCursor doc = example.find(query );
while(doc.hasNext())
{
System.out.println(doc.next());
}
答案 0 :(得分:0)
Pattern path = Pattern.compile("Programing");
BasicDBObject query = new BasicDBObject();
query.put("Path", path);
DBCursor doc = example.find(query );
while(doc.hasNext())
{
System.out.println(doc.next());
}