Questions tagged [mongo-java]

Some useful links:

315 questions
9
votes
1 answer

MongoException: java.lang.OutOfMemoryError: GC overhead limit exceeded

I am bulk writing to MongoDB and get an OOM exception (java.lang.OutOfMemoryError: GC overhead limit exceeded). I have two questions: Does the OOM come from the Mongo Client Driver or MongoDB Server? Is there a clue why the OOM happens? FO…
Tom
  • 5,848
  • 12
  • 44
  • 104
9
votes
1 answer

Difference in $geoWithin and $geoIntersects operators?

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.…
Dev
  • 13,492
  • 19
  • 81
  • 174
9
votes
2 answers

MongoDB list available databases in java

I am writing an algorithm that will go thru all available Mongo databases in java. On the windows shell I just do show dbs How can I do that in java and get back a list of all the available databases?
Max Doumit
  • 1,065
  • 12
  • 33
9
votes
3 answers

how to execute mongo admin command from java

I want to execute soem admin command with parameters from java. The commands are: { enablesharding : "test" } { shardcollection : "test.test_collection", key : {"number":1} } How can I do it from java driver? The following code doesn't…
Julias
  • 5,752
  • 17
  • 59
  • 84
8
votes
3 answers

Get value from Embedded Document Mongo Java

I have the following document in mongo: > { "_id": ObjectId("569afce4b932c542500143ec"), > "date": "2016-1-17T2:31:0Z", > "day": NumberInt(17), > "model1": { > "date": "2016-01-17T02:31+0000", > "MondayModel": { > …
DevilCode
  • 1,054
  • 3
  • 35
  • 61
7
votes
5 answers

Java MongoDB save multiple documents at once

I Have a list of updated objects/documents i need save all the objects in the list at once. I saw save() in MongoTemplate but it can take single document at a time. Is there any way to save multiple documents at once or i need to call save in loop…
7
votes
2 answers

Why eq doesn't exist for mongo-java-driver?

I've found in mongodb tutorial for java about how to query from mongo collection but the eq which they use doesn't work for me! Do you know how to filter documents from a collection with mongo and java? This is my try: package Database; import…
W W
  • 769
  • 1
  • 11
  • 26
7
votes
2 answers

Use a single MongoClient across a JavaEE web service

After reading the mongo documentation that says each instance of a MongoClient handles its own pooling, how would I go about only having one instance across my whole application? This seems like it could be a scenario for using a singleton bean, but…
Matt Williams
  • 1,198
  • 1
  • 10
  • 27
7
votes
4 answers

How to find documents matching multiple criteria

I'm trying to query a collection using operands AND'd together. I've got the shell version working: db.widgets.find({color: 'black, shape: 'round', weight: 100}) I'm unable to find the Java equivalent (using the native driver). I've tried various…
Pepster K.
  • 339
  • 2
  • 5
  • 17
6
votes
4 answers

Spring data mongodb not closing mongodb connections

I am using spring-data-mongodb (1.7.0.RELEASE) with spring-webmvc framework for my web application. I am using basic CRUD functions using mongoRepository but i am not closing mongo connections in my code cause i thought that spring-data-mongodb will…
vivex
  • 2,496
  • 1
  • 25
  • 30
6
votes
1 answer

How to execute full text search command in MongoDB with Java Driver ?

Mongo and Java gurus. Our team decided to use full text search API, introduced recently in MongoDB. However, we found some difficulties executing the command using the Java MongoDB driver. here is my code I am using : public BasicDBObject…
Adelin
  • 18,144
  • 26
  • 115
  • 175
5
votes
3 answers

Mongo Database save data from Map

I have the below code which works: if (aDBCursor.hasNext()) { DBObject aDbObject = aDBCursor.next(); aDbObject.put("title", "Test Title"); ArrayList department = new ArrayList(); DBObject nested1 = new…
Marc Stevens
  • 353
  • 2
  • 4
  • 11
5
votes
2 answers

Is there a web server running in mongo?

When I start the config server I can see the following line in the logger: [websvr] admin web console waiting for connections on port 27017 So, I wonder if mongo use a web server for maintaining config data?
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
5
votes
1 answer

MongoDB query on multiple fields

I am storing some numbers in mongodb. For e.g. num1:5 num2:10 num1:11 num2:15 I want to find documents where for e.g. if I pass '7' the query should check if 7 lies between num1 and num2 and must return me this document. I tried BasicDBObject…
koustubhC
  • 157
  • 2
  • 15
5
votes
2 answers

Can mongoDB compare field names instead of field values?

When defininng the to be returned fields (collection.find(q, fields)), does (how does) mongoDB support to compare the field names (and not the value)? E.g. to select a range of fields based on their name without regard to their value. Assume the…
1
2
3
20 21