Questions tagged [mongo-java]

Some useful links:

315 questions
0
votes
1 answer

MongoD JAVA insert vs. update and compare changes

I have a large collection of roughly 3.2 million records, this collection data is being updated monthly but the source data is being fetched as-is, meaning I don't get just the updated records but everything. In terms of performance, is it better to…
karel lahmy
  • 397
  • 1
  • 5
  • 15
0
votes
1 answer

Simulating Mongo Write Lock to measure performance

I am trying to simulate a mongo write lock using mongo 1.8.0, but unable to see correct expected results. I create two mongo collections in two different dbs on the same server. I create an array of DBObjects and insert them in both collections.…
Skynet
  • 657
  • 2
  • 9
  • 25
0
votes
1 answer

java mongo custom object id userid

We have a User doc in Mongo DB and want to use the _id field as the userID field and increment it. i found a counter("user") JS method in Mongo docs (http://www.mongodb.org/display/DOCS/Object+IDs). From the Mongo Shell, i can invoke, …
Blue Sky
  • 807
  • 1
  • 15
  • 36
0
votes
1 answer

Is it possible to populate additional fields with a json object for Mongo java?

I know there is a BasicDBObject that allows you do go: BasicDBObject info = new BasicDBObject(); info.put("x", 203); info.put("y", 102); The issue I have is that the value can only be a primitive type. I have a json object that I want to store…
Rolando
  • 58,640
  • 98
  • 266
  • 407
0
votes
1 answer

Java: Mongo fails to assert the right number of documents inserted

I have a following test @Test public void testPutDocuments() throws Exception { final DBObject document01 = new DBObject(); document01.put("uniqueId", "001"); document01.put("rv", "values"); …
daydreamer
  • 87,243
  • 191
  • 450
  • 722
0
votes
1 answer

How to find the smallest number in a mongo query?

I have the following objects in my mongo db: { "type" : "timetype" "time" : "18" } { "type" : "timetype" "time" : "5" } { "type" : "timetype" "time" : "43" } { "type" : "timetype" "time" : "23" } And my java code looks like:…
Grammin
  • 11,808
  • 22
  • 80
  • 138
-1
votes
1 answer

Error 11000 in Mongo Java, DuplicateKeyException

I have a piece of code, as following and have been getting this error in Java. coll is the collection where I need to insert data. I was hoping mongodb would automatically generate the ids so putting the same data (in a for loop) wouldn't matter but…
-1
votes
1 answer

JSON reader was expecting a name but found ':'. in Mongodb Java

I am storing my data from external file to mongodb in localhost. it's quite huge dataset of volume 1.70GB with ~10 million tweets. While importing from file to mongodb it shows me the error "JSON reader was expecting a name but found ':'" I dint…
prabhu
  • 103
  • 1
  • 3
  • 15
-1
votes
1 answer

Not able to get the aggregate result in mongo embedded document by querying

Issue in querying the embedded document in mongo db. I am trying to get the conversationId for the users but it returning null. Sample document: { "_id" : ObjectId("5787391f191fda3a4430c749"), "conversationId" : "fWFGIr0xAbQytmVcQIPV", "user" :…
-1
votes
1 answer

grails beans definition returns null pointer exception

I'm trying to define a bean for class that will handle connections to mongodb beans definition beans = { dbCon(DbConnImpl){ mongoClient = ref("mongo_client") dbName = "myDb" } mongo_client(MongoClient, "localhost",…
royB
  • 12,779
  • 15
  • 58
  • 80
-1
votes
1 answer

Is there any way I can use $where with aggregate

Is there any way I can use $where in aggregate. my collection is {"id":5,score:70}, I tried {$match:{$where:"this.id>5&&this.score>70"}}, but it doesn't work, I have to use where as my api is ainterface to mong,which is receiving query from user in…
Phalguni Mukherjee
  • 623
  • 3
  • 11
  • 29
-1
votes
3 answers

How can I do select * queries through map reduce in mongodb

I want to select all the columns of a document through "Map Reduce", but not able to understand how to write map function in this case.In short I want to do something like select * in SQL
Phalguni
  • 61
  • 1
  • 9
-1
votes
2 answers

MongoDB DBCollection.insert() returns null as WriteResult?

Will insert(List) return null? WriteResult result = collection.insert(List); result.getError() -->Throws NullPointeException In the above snippet, what may cause the return of null for WriteResult?
vivek_jonam
  • 3,237
  • 8
  • 32
  • 44
-2
votes
1 answer

How to aggregate values in an array of objects in MongoDB

I store documents from cars and want to get the temperature of all Mercedes cars as an array, how should the query be in Mongodb? { "_id" : { "$oid" : "5880ff305d15f416c89457b7" }, "car" : "mercedes", "engine" : { "sensor" :…
-3
votes
1 answer

How to run a mongo query from java program?

The query that we run from a mongo-shell, I want to run the same query from a java program. How can I do that?
1 2 3
20
21