Questions tagged [mongo-java]

Some useful links:

315 questions
0
votes
1 answer

$unset for subarray in mongodb does not work

I have a collection of the form { "student_id":"123", "test": [ { "date_created": "12/3/2013" } ] } I want to unset the date field. I use the following query: db.student.update({ "student_id" : "1234"} { "$unset" : { "test.$.date_created" :…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

Unwind does not show all data

I have a collection which looks like this: { "consultation_type" : "1", "encounter_id" : "12345" } I am applying the following query: db.encounter.aggregate([{ "$unwind" : "$vitals"},{ "$match" : { "$eq" : [ "$vitals.spirometer.FVC" ,…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

MongoDB lat long search with 2D sphere indexing in Java application

I have a case where I need to search nearby merchants of the logged in Users's location. The user's current city's lat long to be used for comparison with the Merchant data stored in our database which is like this - { "merchant_id" :…
0
votes
1 answer

Iterating in the reduce function without knowing the key name

I have a map functions as: emit(this_id,this), now I want to iterate through each key in the reduce function,is their a way I can proceed with this problem, having no clue how to proceed.
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

Join Through Map reduce

I have one collection in which student_id is the primary key: test1:{student_id:"xxxxx"}, I have another collection in which student_id is inside array of collection: class:{"class":"I",students:["student_id":"xxxx"]} My problem is I want to join…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

Passing more than one $Unwind object from java driver

The mongo java driver takes var args for aggregate method, I have an API in which $unwind objects get's created dynamically and its number is not fixed. how can I pass it through Mongo Java driver aggregate method, as it needs each object to be…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
0 answers

How to Pass sort query to Mongo through Java driver "mapReduce" function

I want to do sorting through Java map reduce in mongo. How to pass the sort query through Java API? I am using this command: { "mapreduce": "orders", "map": "function map(){ var items_out={ items:[] }; for(i in this.items){ …
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

$Where gives error

I have a collection containing data: { "_id" : ObjectId("51dfb7abe4b02f15ee93a7c7"), "date_created" : "2013-7-12 13:25:5", "referrer_id" : 13, "role_name" : "Physician", "status_id" : "1", } I am sending the query: cmd { "mapreduce"…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

"Map Reduce" reduce function finds value undefined

I have the following collection: { "_id" : ObjectId("51f1fcc08188d3117c6da351"), "cust_id" : "abc123", "ord_date" : ISODate("2012-10-03T18:30:00Z"), "status" : "A", "price" : 25, "items" : [{ "sku" : "ggg", "qty" : 7, …
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

Exact Reduce function

I have a collection of the type : { "_id" : ObjectId("51f1fcc08188d3117c6da351"), "cust_id" : "abc123", "ord_date" : ISODate("2012-10-03T18:30:00Z"), "status" : "A", "price" : 25, "items" : [{ "sku" : "ggg", "qty" : 7, "price" :…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
0
votes
1 answer

Java MongoDB aggreate query

I need guidance in translating the following MongoDB query in to a Java program that uses a Java DB driver to retrieve data. Any guidance would be really appreciated. db.playerscorecollection.aggregate([ { $unwind: "$scorearray" }, {…
user1965449
  • 2,849
  • 6
  • 34
  • 51
0
votes
2 answers

How to define “$add :["$count" , "$count1"]” aggregation with mongo-java implementation?

Below is sample document structure. db.volume_statistics.insert({ "client": "SER", "message": "Sample_v02RQ", "GDS": "SABRE", "daily": 240000, …
Jai Kishore
  • 77
  • 1
  • 2
  • 7
0
votes
1 answer

Set Date and Time in Different Field in MongoDB

I am inserting Date Object from Java to Mongodb, mongo ISODate(...) stores Date with Time, my requirement is to Store both in different field. is this possible ? note : don't want solution that stores milliseconds instead of date. want to store only…
Yogesh Prajapati
  • 4,770
  • 2
  • 36
  • 77
0
votes
2 answers

Retrieve Array Of Documents in MongoDB

I have a MongoDB Document like as follows { "_id":1, "name":"XYZ" ExamScores:[ {ExamName:"Maths", UnitTest:1, Score:100}, {ExamName:"Maths", UnitTest:2, Score:80}, {ExamName:"Science", UnitTest:1, Score:90} ] } I Need to retrieve this document so…
user1198485
0
votes
2 answers

Mongodb count with queries have poor performance

Counting the number of records in a collection that is matched by a query even on an indexed field takes too much time. For example lets say there is a collection consists of 10000 records, and there is an index on the creationDate field of this…
cubbuk
  • 7,800
  • 4
  • 35
  • 62
1 2 3
20
21