FAQ Database Discussion Community


How to use Mongo Bulk Update using its Java Driver?

mongodb,mongo-java
I am using Mongo Bulk Update using its Java Driver 2.13. MongoClient mongo = new MongoClient("localhost", 27017); DB db = (DB) mongo.getDB("test"); DBCollection collection = db.getCollection("collection"); BulkWriteOperation builder = collection.initializeOrderedBulkOperation(); builder.find(new BasicDBObject("_id", "1")).update(new BasicDBObject("_id", "1").append("name", "dev")); I got the following exception: Caused by: java.lang.IllegalArgumentException: Update document keys must start with...

Difference in $geoWithin and $geoIntersects operators?

mongodb,geospatial,mongo-java
What is the difference in $geoWithin and $geoIntersects operators in mongoDB? If I am looking for coordinates (using default coordinate reference system), $geoWithin and $geoIntersects will return the same result. Please correct me if I am wrong. Any simple use case for understanding the difference would be appreciated. ...

In MongoDB, how do I search in an array of sub-documents?

java,mongodb,mongo-java
I have a survey document in mongodb, each survey have surveyRefId for unique identification. I am not able to understand how to find sub-documents having questionType = hard in documents whose surveyRefid = 377 or 360. Here is a sample document: { "json": { "surveyRefId": 377, "surveyName": "survey on sociology",...

MongoDB select's/find seems to have the same performance for a larger amount of data

java,database,mongodb,mongodb-java,mongo-java
I'm measuring the performance of MongoDB with its native driver. For the insert operation, the more I inserted the more time it took. However, with selecting, I have 500.000 documents (inside 1 collection) with each document having 4 other embedded, small documents inside of it. I performed a select query...

Check if User object exists in @DBRef List

spring,mongodb,spring-data,mongo-java,dbref
I'm making use of MongoDB, Spring Data and Spring MVC. I have a user model which has a list of contacts: class User { @DBRef private List<User> contacts = new ArrayList<User>(); public List<User> getContacts() { return contacts; } } I currently have 4 users inside my database. 1 user has...

How does Write Concern in MongoDB Work at Thread level?

mongodb,database-administration,mongo-java,replicaset
As I see we can set write concern from the application, I was wondering how will MongoDB handle a scenario like this: Lets say we have two task/Process (P1 and P2) running on same database (The database has a replica set of three nodes, 1 primary and 2 secondary). P1...

How to retrieve a value from mongoDB?

java,mongodb,mongodb-query,mongo-java,mongo-java-driver
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, ZoomedProductImage list [ ] =...

Confusion in by default chunk size in GridFS

mongodb,gridfs,mongo-java
MongoDB manual says by default chunk size is 255K. Its current Java API says its 256K. Which one is right or both?...