Questions tagged [mongodb-java]

MongoDB is a scalable, high-performance, open source, document-oriented database. This tag is used for questions related to the Java language bindings and drivers for MongoDB.

Java Language Center

Java Driver

Basics

Specific Topics and How-To

Reference

1045 questions
0
votes
0 answers

Mongo DB grouping datatype changes

I came across an odd occurrence while using mongodb + their java driver. When I do a grouping query the datatype for the key changes from an int to a double. (ie. I am grouping on a key for 'hours', which is stored as an int within all the objects,…
CasualT
  • 4,869
  • 1
  • 31
  • 53
0
votes
1 answer

Java MongoDB clients and MongoS Sharding

I know that if I create a connection to MongoDB in Java to a replica set using a list of ServerAddresses (using this function) with ReadPreference.SECONDARY, the client will balance the reads across the replica set, preferring nodes with shorter…
spitzanator
  • 1,877
  • 4
  • 19
  • 29
0
votes
1 answer

Are GridFS Java objects thread safe?

I know that Java com.mongodb.Mongo objects are thread safe, but if I use the database returned from it to create a GridFS object, is that GridFS object also thread safe? Thanks.
Rintoul
  • 823
  • 2
  • 13
  • 16
0
votes
1 answer

Java JAR does not contain correct dependencies

I am attempting to create a uberjar of my java project with a dependency for the mongodb-java-driver found here which includes the com.mongodb.* packages. Currently I have tried using leiningen versions 2.0.0-preview4 and 1.7.1, and…
Ian
  • 483
  • 1
  • 5
  • 14
0
votes
2 answers

count values inside an array of an object in mongodb

I am trying to gather all the hashtags i have in a collection of tweets in mongodb and i want to count how many times each hashtag appears in tweets. hcoll is the collection of hashtags that is created with this code. BasicDBObject key = new…
Makis Tsantekidis
  • 2,698
  • 23
  • 38
0
votes
2 answers

Java - Storing a string in Mongo as a object without any type

I have String toInsert = "somestring"; insert(toInsert); and insert(String toInsert) { DBObject dbo = new BasicDBObject(); dbo.put("value" : toInsert); } In Mongo, this is saved as {"value" : "somestring"} But I would like it to be…
Skynet
  • 657
  • 2
  • 9
  • 25
-1
votes
1 answer

Map Reduce functions executes on shell but fails to compile via MapReduceCommand java api

I am trying to run the following command via the mongo Java API - MapReduceCommand class. During debug time the MapReduceCommand mrc seems to hold the following. { "mapreduce" : "inColl" , "map" : "function mapf(){var vr = new…
Skynet
  • 657
  • 2
  • 9
  • 25
-1
votes
1 answer

Morphia throws error when the field was changed its type from String to enum: No enum constant

In DAO class I use with Morphia I have replaced the String filed type to enums.Currency and I expect that everything will work fine, when the data is retrieved from the db: was public String currency; now public Currency currency; where…
Eljah
  • 4,188
  • 4
  • 41
  • 85
-1
votes
1 answer

How to update a document and set a field's value using MongoDB Java?

In sql the statement look like: UPDATE table SET table.password = pPassword WHERE (table._id = pid); How does this work for Java and MongoDB? function(){ BasicDBObject cBsonFilter = new BasicDBObject(); cBsonFilter.append(COL_id, new…
ru4ert
  • 998
  • 2
  • 14
  • 25
-1
votes
1 answer

Unable to instantiate MongoDB Document class with Map containing Any values

Been recently trying to compress within a single Map all the values that will go within my $set clause when performing an upsert to MongoDB. However, this was previously done with a single typed Map[String, Long] which worked. However, since I know…
czr_RR
  • 541
  • 5
  • 16
-1
votes
1 answer

JSON parsing fails for string but passes for number in Java

I am writing a parser for incoming JSON data with no definite structure for the values within the JSON. For example a given key within the parent JSON can have an integer or a string value. In some cases it can also be another JSON string. When…
Navin Nagpal
  • 640
  • 10
  • 25
-1
votes
1 answer

How to display subdocuments in a document using the MongoDB Java driver

Given this document: Document{{ _id=5a66fceba07b4ba90a19ee07, address=Document{{ building=8405, coord=[-74.02521709999999, 40.6224629], street=5 Avenue, zipcode=11209 }}, borough=Brooklyn, …
yash vaidya
  • 9
  • 1
  • 4
-1
votes
1 answer

How we can write this MongoDB query in Java?

([{ $match: { "Publication_Date": { $gte: ISODate("2003-01-01T00:00:00.0Z") }, } }, { $group: { _id: { $year: "$Publication_Date" }, total: { $sum: 1 …
-1
votes
1 answer

MongoDB query to capitalise first letter in existing database

Here is the problem, I want to capitalise the first letter of a name in my existing database, just wanted to know if there is any query so that i can make it possbile. what i want -- in my database so many names is in unformatted ways.. like…
-1
votes
1 answer

MongoDb database connection using java and authentication with 3.0.0 version

I have MongoConnectionUtils this file I have dependecy below mongo-java-driver org.mongodb mongo-java-driver 3.0.0 public class…
Kamini
  • 690
  • 2
  • 13
  • 36
1 2 3
69
70