{
"_id" : ObjectId("5888ae5f1495062544ac7951"),
"site" : "gfhfh",
"keywords" : {
"keyword 1" : {
"dailyranks" : {
"2017-01-28" : {
"rank" : 1,
}
**Dynamic data should add here by date **
}
}
}
}
I have tried to insert keyword rank by date. I want to add keyword rank each day. but it doesn't insert only update date and values. I have used following code in java.
for (DBObject dbo : result) {
DBObject keywordlist = (DBObject) dbo.get("keywords");
BasicDBObject a = new BasicDBObject();
for (String keyword : keywordlist.keySet()) {
DBObject rank = getRank();
BasicDBObject rankdate = new BasicDBObject(date, rank);
BasicDBObject aa = new BasicDBObject("dailyranks", rankdate);
a.append(keyword, aa);
}
coll.update(dbo, new BasicDBObject("$set", new BasicDBObject("keywords", a)), true, false);
}