MongoDB使用Java创建索引

时间:2018-03-28 16:36:42

标签: java mongodb

我正在尝试在我的收藏中创建索引,而我几乎就在那里。但是,我不知道我的代码中的partialFilterExpressionboolean值如何。我试过跟随 -

DBCollection TransmissionCharge = db.getCollection("Charge")
BufferedReader br = new BufferedReader(new FileReader("src\\test\\resources\\datasheets\\Charge.json"))

            String name= "TrIndex"
            String Charge = null;
            while ((Charge= br.readLine()) != null) {

                DBObject record = (DBObject) JSON.parse(Charge);
                TransmissionCharge.createIndex(**record,name**)
            }
            br.close()

MongoQuery如下 -

db.Charge.createIndex({"_id.@Name": 1, "_id.InstanceId": 1, "_id}Recipient":1, "_id.Code":1 }, { "name": "RecipientIdx", "partialFilterExpression": {"_id.revenueRecipient": {$exists:true}}})

如何在我的java代码中获取partialFilterExpression$exists:true

0 个答案:

没有答案