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
1 answer

Mongo connection pooling and max connections

My application is running mongodb 2.4.8 using 2.11.2 version of java driver. It always end up with mongo taking too much cache on my RHEL when there are too many objects in the database. Almost 4GB of my total 8GB is mostly cached. Even if i try to…
Akhil Achuthan
  • 141
  • 3
  • 16
0
votes
1 answer

Mongodb stored function in aggregation

I am using below query to fetch data from mongo-db: db.FetchedUrl.aggregate({ "$match": { "type": db.eval('echoFunction(\"news\")') } }) This is my stored function: db.system.js.save({ _id: "echoFunction", "value": function(x){return…
shivam
  • 511
  • 3
  • 13
0
votes
1 answer

" fields stored in the db can't have . in them."

I try to rewrite this mongodb query (that works in command line): db.projects.update({"tools.name" : "gitlab"}, {"$set" : {"tools.$.status" : "error"}}) in java: DBObject queryUpdate = new BasicDBObject("tools.name",…
Tommy V
  • 177
  • 2
  • 8
0
votes
1 answer

MongoDB Java API - whats the equivalent for db.collection.remove()?

As explained here, db.bios.remove() deletes all the documents from the bios collection of currently connected DB. What is the equivalent method for this functionality in MongoDB Java API? I did not find any methods like DB.removeCollection(..) or…
sanbhat
  • 17,522
  • 6
  • 48
  • 64
0
votes
1 answer

How to pass BasicDBList of $OR criteria to QueryBuilder?

My app is dynamically generating a mongo query via a QueryBuilder. I'm trying to make it so that the passed text can be compared against several fields in my collection. I need to iterate through data in order to know what to add to the $OR (…
Erich
  • 499
  • 1
  • 13
  • 34
0
votes
1 answer

Get values from array in inner document in mongodb

how can I get a field from a inner document in mongodb?? For example if I give a field called "idMovie", I would get the rest of field that correspond to this idMovie. I'm using this code: MongoClient mongo = null; DBCursor cursor =…
hcarrasko
  • 2,320
  • 6
  • 33
  • 45
0
votes
2 answers

MongoDB - change value where key matches

I have a user, and inside I keep a list of items he has rated. > db.users.findOne() { "_id" : ObjectId("5321985944aebf2ca6f2075f"), "ratings" : [ { "532192d344aebf2ca6f2075e" : 0 }, { …
0
votes
2 answers

looking for a field inside a mongodb document

I'm trying ask if a field exist inside a document inside another document in an mongodb database using java driver. The field that I asking for is idMovie. For example, I expect that it print in the console "idMovie value already exist" if idMovie…
hcarrasko
  • 2,320
  • 6
  • 33
  • 45
0
votes
2 answers

Mongodb returns empty array with query builder

I have the following documents in collection { "_id" : ObjectId("53202b3644aec3ce32afc40b"), "_class" : "com.brand.domain.House", "bedrooms" : 2, "uid" : "URErlrjldVhW", "price" : NumberLong(200), "type" : "RENT", …
Shahzeb Khan
  • 3,582
  • 8
  • 45
  • 79
0
votes
1 answer

Selective replication in mongodb

I have two MongoDB running in two different servers connected via LAN. I want to replicate records from few collections from server 1 to collections in server 2. Is there any way to do it. Below is the pictorial representation of what I want to…
Maria
  • 1,161
  • 3
  • 12
  • 21
0
votes
0 answers

Matching object name in nested collection full text search mongodb

We have got an nested object in the mongo db collection e.g. profile object has got array of address and contacts data. { "_id" : "f714af57-b4bd-4c1d-b09c-88f71a446262", "_class" :…
Rakesh Goyal
  • 3,117
  • 8
  • 39
  • 69
0
votes
1 answer

How to change the chunksize and Retrieve specific chunk in Mongodb Gridfs?

I am pretty much new in Mongodb now what I want to do is to insert a pdf file of 3MB using JAVA driver and want change the chunk size from 256 to 1mb and then want to retrieve the second chunk say 2nd page of the pdf document. How can I do…
user2168912
0
votes
0 answers

Query data inside embedded array in MongoDB

I've an data in a collection as below. { "date":"01-01-2014", "details": [ {"name":"abc", "address":{ "city":"abc" , "state":"abc" }, {"name":"xyz", "address":{ "city":"xyz" , "state":"xyz" …
madhuram2468
  • 41
  • 1
  • 5
0
votes
1 answer

how to retrieve value from the mongodb using spring frame work

how to retrieve the value from the mongodb using springframe work , can anyone share the code or tell the procedure . and how to put the values comes from the database store them in a csv file. Thanks Navneet
NAVNEET MATHPAL
  • 170
  • 1
  • 1
  • 10
0
votes
1 answer

how to represent this ohlc mongo query using spring mongodb aggregation function

I'm wring an ohlc query for the stock, and the data is like: { "_id" : "52f97cba03646d746011199a" , "tradedAmount" : { "amount" : 1050000000 , "currency" : "USD"} , "tradedPrice" : { "amount" : 10500 , "currency" : "CNY"} , "orderBookIdentifier" :…