0

I am trying to createIndex in my collection and I am almost there. However, I do not know how do I partialFilterExpression and boolean value in my code. I tried following-

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()

the MongoQuery is as follows-

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

How do I get partialFilterExpression and $exists:true in my java code

anumeha
  • 25
  • 8
  • Possible duplicate of [How to parse JSON in Java](https://stackoverflow.com/questions/2591098/how-to-parse-json-in-java) – Roman Vottner Mar 28 '18 at 17:25
  • In addition to that your code is confusing. Please stick to the Java conventions and start your variable names with a lower case letter. Plenty of JSON frameworks allow to read in a JSON from an arbitrary input stream whch you can easily obtain via `getClass().getResourceAsStream("/datasheets/Charge.json")` – Roman Vottner Mar 28 '18 at 17:28

0 Answers0