Some useful links:
Questions tagged [mongo-java]
315 questions
2
votes
1 answer
update BasicDbList element from java
I have a BasicDbObject like the following :
{
"_id" : ObjectId("57060562ea9bcdfgs50ffdc7"),
"name" : "g3",
"detaillist" : [
{
"code" : "123",
"School" : "LDC",
"Friend" : "Archana"
},
…

Gayatri
- 53
- 5
2
votes
1 answer
Java MongoDB how to use BasicDBList as $in parameter
I have a MongoDB Collection like this, containing details of game players:
{
...
"fields" : {
"playername" : "Koala",
...
}
...
}
And I want to get the IDs of the players in an array. So, for example, I do…

Roi
- 188
- 1
- 2
- 7
2
votes
0 answers
Minimum configuration for writing to Mongo replica set in Java client
I'm new to morphia.
I'm using morphia and mongo-java-driver.jar to talk with a replica-set (I need it for a cluster) through a Java program. I wrote the sample program below:
public static void createDBConnection() {
try {
…

Narendra
- 151
- 2
- 12
2
votes
1 answer
How to use Mongo Bulk Update using its Java Driver?
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…

Dev
- 13,492
- 19
- 81
- 174
2
votes
3 answers
How can I authenticate any database with given username and password in Mongo Java Driver 2.13.0?
Previously I could use db.authenticate(String username, char[] password) method. With 2.13.0, how can I achieve this?

Dev
- 13,492
- 19
- 81
- 174
2
votes
1 answer
group by date in mogodb query without considering time
I have the following code:
DBObject groupFields = new BasicDBObject("_id", "$Date");
groupFields.put("count", new BasicDBObject("$sum", 1));
DBObject groupBy = new BasicDBObject("$group", groupFields);
stages.add(groupBy);
DBObject…

HMdeveloper
- 2,772
- 9
- 45
- 74
2
votes
1 answer
java mongodb driver no exception thrown on duplicate keys
I'm using spring framework with mongoTemplate. bean initiation:
public
@Bean
MongoTemplate mongoTemplate() throws Exception {
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory());
…

royB
- 12,779
- 15
- 58
- 80
2
votes
3 answers
Mongo Connection Pooling(Changing the size of connection pool)
How to change the mongo connection pool size?
I have seen it is 100 by default. Is there a way to change this value?
I dont want to do it via spring, is there a way to configure it via MongoClient?
There is an option i see about mongoClientOptions…

neoeahit
- 1,689
- 2
- 21
- 35
2
votes
3 answers
MongoDB : Hint with multiple columns in java query example
In a collection subject, in which the documents have social,maths and english as fields. If I need to provide a hint to the following find query, how do I do it?
db.subject.find({maths : 30, social :10,english : 20});
user3631644
2
votes
1 answer
Mongo aggregation in java
Hi my mongo collections contains following documents:
{
"_id" : ObjectId("539efd5b254bb5f65c9da94e"),
"iInfo" : [
{ "ifout" : 0, "iferror" : 0, "ifdes" : "N/A", "ifin" : 0 },
{ "ifout" : 0, "iferror" : 10, "ifdes"…

Neo-coder
- 7,715
- 4
- 33
- 52
2
votes
1 answer
compare two collections in mongodb using java or an simple query
I am having following document (Json) of an gallery,
{
"_id": "53698b6092x3875407fefe7c",
"status": "active",
"colors": [
"red",
"green"
],
"paintings": [
{
…

Parag Vaidya
- 81
- 1
- 7
2
votes
1 answer
MongoDB Java client - why does `sort` seem to break my query?
I have not been able to make a query work when using sort. I expect the results of a query to be exactly the same as if I were not using sort, except the results should come in sorted, of course, but what happens is that when using sort I get…

Renato
- 12,940
- 3
- 54
- 85
2
votes
1 answer
What is the effect of violating a unique index constraint in MongoDB's java driver?
I need to ensure an insert occurs and if it fails the system should throw an error.
Do I need to check the insert occurred myself or will the Java driver throw an error if an insert is not possible?

Inverted Llama
- 1,522
- 3
- 14
- 25
2
votes
1 answer
Sort array of subdocuments in mongodb with java
uI have an array of subdocument in the document of mongodb.
I want to sort those subdocuments.
I found it is possible to sort while updating the array.
link: http://docs.mongodb.org/manual/reference/operator/update/sort/
I want to do this in…

Colleen Mayer
- 184
- 8
2
votes
2 answers
Load Balancing Between Mongos
I have created a sharded environment, I am using two mongos. Is their a way I can load balance between the two "mongos",Because presently I found the Mongo client uses one of the two.Or do I have to write my own load balancer?

Phalguni Mukherjee
- 623
- 3
- 11
- 29