使用正则表达式在Mongo数据库中进行嵌套数组搜索

时间:2016-04-05 06:20:54

标签: mongodb mongodb-query mongo-java mongo-java-driver

在嵌套数组中搜索的内容是什么:

"_id" : "123",
"Array1" : [
    {
        "field1" : {
            "nestedArray1" : [
                {
                    "content" : "This string inside %nestedArray%",
                }
            ]

        },


    }
],

我尝试使用以下正则表达式 Array1.field1.nestedArray1.content

Document doc = new Document();
doc.append("Array1.field1.nestedArray1.content", new Document("$regex", ".*" + "%nestedArray%" + ".*"));

但我无法得到正确的结果..上述查询的格式正确

0 个答案:

没有答案
相关问题