Questions tagged [mongo-java]

Some useful links:

315 questions
0
votes
2 answers

Not able to create covered query in MongoDB

I am facing problem to create covered query. I am using Mongo 3 latest version. Here is my sample data which I have inserted 10006 documents into MongoDB. db.order.insert({ _id: 1, cust_id: "abc1", ord_date: ISODate("2012-11-02T17:04:11.102Z"),…
sus007
  • 297
  • 3
  • 9
0
votes
3 answers

How long will a mongo internal cache sustain?

I would like to know how long a mongo internal cache would sustain. I have a scenario in which i have some one million records and i have to perform a search on them using the mongo-java driver. The initial search takes a lot of time (nearly one…
Sree Karthik S R
  • 335
  • 2
  • 3
  • 10
0
votes
1 answer

Update Double Array using Mongo 3 Java driver

Looking to run an update on a document in a mongoDB using the mongo 3+ java driver. The document is structured as follows and as you can see in the hours there is a double array. new Document() .append("qnx", "MongoDB") …
DevilCode
  • 1,054
  • 3
  • 35
  • 61
0
votes
2 answers

Refering MongoDB indexes with find() / aggregate()

Is there any way to force a find() or aggregate() query to refer/see a particular existing index in MongoDB. I am asking about the the scenario when a collection has more than one compound indexes.
excoder
  • 23
  • 6
0
votes
0 answers

Assigning value to Java variable after querying from Mongo DB with Mongo Java driver(3.x)

How to assign the values queried from MongoDB to a variable in Java using Mongo Java Driver? int usr1count; MongoClient mongoClient = new MongoClient("localhost", 27017); MongoDatabase mongoDatabase =…
svs teja
  • 957
  • 2
  • 22
  • 43
0
votes
0 answers

Can not connector to replica set with Java driver, works with Node.js driver

Here is how I connect to my replica set with Node.js: var MongoClient = require('mongodb').MongoClient; var url = 'mongodb://ec2-54-237-60-17.compute-1.amazonaws.com:27017/test?readPreference=secondary'; MongoClient.connect(url, function(err, db)…
mravey
  • 4,380
  • 2
  • 21
  • 31
0
votes
1 answer

Confusion in by default chunk size in GridFS

MongoDB manual says by default chunk size is 255K. Its current Java API says its 256K. Which one is right or both?
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

Unordered bulk update in MongoDB using JAVA

I have MongoDB documents like: {_id:1001, "title":"abc", "author":"xyz"} What is the best way to update author for 1 million such documents? I came to know about the unordered bulk update in MongoDB. How to implement that using Mongo's Java…
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
2 answers

How to retrieve a value from mongoDB?

I am new to mongoDB and using java with mongoDB. I have a json where I want to retrieve the column names and not the value.I also need to store it in two different array. Desired output is: column [ ] = views, AddToCart, AddToWishList,…
Ritesh Sinha
  • 820
  • 5
  • 22
  • 50
0
votes
2 answers

How to add and remove users in MongoDB Java Driver 2.13?

Using terminal, I can add user using db.createUser(user, writeConcern)and remove it using db.dropUser(username, writeConcern) How to add and remove users in MongoDB Java Driver 2.13?
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

Are indexes deleted after deleting file in GridFS?

I am using GridFS MongoDB via JAVA Driver 2.13. I inserted a file: File file = new File("/home/dev/abc.pdf"); GridFSInputFile inputFile = gfs.createFile(file); I removed it using its _id which is p_id in this case: DBObject query = new…
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

How to get data as byte[] using GridFS Java API?

I am using Java-driver 2.13. GridFS takes input as File, InputStream or byte[] in createFile() method on GridFS instance to create GridFSInputFile . But when I tried to fetch data back I do have option only as File or outputStream using…
Dev
  • 13,492
  • 19
  • 81
  • 174
0
votes
1 answer

Bulk upsert using MongoDb BulkWriteOperation throwing IllegalArgumentException

I'm trying to do a bulk upsert using BulkWriteOperation. public BulkWriteResult bulkUpsert(DomainName domainName, Map dbObjectByQueryMap) { BulkWriteOperation bulkWriteOperation =…
Krishna Gollapudi
  • 1,609
  • 16
  • 13
0
votes
1 answer

What is wrong with MongoDB remove query using mongodb java for sub-array of document?

Remove in momgodb using java not giving proper result. Am i missing something? My database is as below. My code for removeing records where index = "7" is as, BasicDBObject whereQuery = new BasicDBObject("nodes.index", new BasicDBObject("$eq",…
Hitesh Vaghani
  • 1,342
  • 12
  • 31
0
votes
2 answers

How to remove duplicate from mongodb when there is not unique key in collection.?

How should I remove duplicate from mongodb collection when there is no unique element? I want to do this in using Java driver. In that below pic some record are same. I want to remove that records. Time is not unique key here. P.S.: I just…
Hitesh Vaghani
  • 1,342
  • 12
  • 31