Skip to main content

All Questions

0 votes
0 answers
53 views

Get document from MongoDB containing all fields but only includes the first element of an array field

Consider a MongoDB collection with documents as follows: [{ "_id": "123", "name": "Bob", "age": 23, "properties": ["a&...
Paul Jose's user avatar
2 votes
1 answer
336 views

MongoDB Java Driver Filter Integer Value of a String

I have MongoDB Document parameter of type "real" number but is represented in the DB as a string- e.g "cId"="200" instead of "cId"=200I have to query the DB for ...
user1843591's user avatar
  • 1,124
6 votes
0 answers
340 views

Mongodb seems to be calling secondary when load increases

We have a mongo db replica set configuration with 1 primary and 2 secondaries. We have set the read preference to primary because one of our secondary is in a remote region and do not want read ...
Crusaderpyro's user avatar
  • 2,222
0 votes
0 answers
674 views

Mongodb Java - Update document replacing a string in field

I am looking for a way to update a document replacing a substring of a field with another value. For example, in my database i have the following field: { "_id": 1, "value":...
Alessandro Valentino's user avatar
0 votes
1 answer
246 views

With the Java Sync MongoDB Driver, how do you acertain the impact of an aggregation pipeline?

I have code in Java that performs an aggregation pipeline roughly: List<Bson> aggUpdate = Arrays.asList( match(...), project(...), lookup(...), ... merge(...) ); AggregateIterable&...
Robert's user avatar
  • 1,322
0 votes
1 answer
440 views

how to replaceOne document in MongoDb with Mongo database command

We have requirement to execute replaceOne operation with db.runCommand() I checked list of commands from here, but i haven't found any command to replace one document. Can someone please suggest us ...
Abhishek Kumar's user avatar
0 votes
0 answers
354 views

Deletion of 1 million records with BulkWrite (DeleteManyModel) taking longer time

I have collection of 5 million records and every time data refresh happens , i wanted to delete Approx. 1 Million records. I am using below java code but it taking 30 Sec to delete. that is to high ...
Bhavesh Modi's user avatar
0 votes
0 answers
300 views

MongoDB $geoNear in aggregation pipeline with the latest Java-Driver

Ok what I am trying to do is to find the proper way to add $geoNear in the aggregation pipeline. I have managed to do that, by adding a org.bson.Document at aggregation pipeline List, but I think ...
Konstantinos Raptis's user avatar
1 vote
1 answer
2k views

Java MongoDB Projection

I am referring mongodb official page for projection where I came across following example where elements of array in subdocument is filtered: https://docs.mongodb.com/manual/reference/operator/...
Hamid's user avatar
  • 757
1 vote
1 answer
652 views

Query a stored procedure in mongodb using spring boot

I want to query a stored procedure in mongodb. I can query it using the command line tool but facing issue while querying using java.The piece of code(last two lines) that is throwing error is : ...
ak03's user avatar
  • 31
1 vote
1 answer
712 views

How to return only 1 field in MongoDB?

I'm trying to get the order number where a transactionId is equal to another variable I have in my code. My tolls.booths collection looks like this In my code, def boothsException = booths.find([ "...
Matt's user avatar
  • 69
0 votes
0 answers
369 views

Bucket aggregation and grouping in MongoDB Java driver

I do a short query to get some data from MongoDB using MongoDB Java Driver v 3.2. I am using Bucket and Unwind aggregation to make my work and result a bit meaningful. I made a filter based on a ...
Mos's user avatar
  • 11
0 votes
1 answer
164 views

how to keep special keys in filed of mongoDB documents and remove extra keys in there?

suppose that I have mongoDB collection that has documents like below { "_id" : ObjectId("5cb2dd4d378a8e2484e7bb69"), "name":"ali", "creator" : { "name":"user1", "code":2, ...
Mr White's user avatar
  • 124
1 vote
2 answers
31 views

Optimize set and project operation

An intermediate output of our aggregation pipeline is as follows: { "_id" : { "$oid" : "..." }, "requestId" : "REQ4", "scrips" : ["3553", "5647", "1234", "0007"], "matched" : [{ "settlement" : "9001" ...
IUnknown's user avatar
  • 9,635
0 votes
1 answer
125 views

Filter output from multiple collections

Suppose we have an array of scrips as such: ["xxxxx1","xxxxx2","xxxxx3","xxxxx4"] We have the following collections of scrips existing in db: Executed:{"_id" : ObjectId("xxx"),"scrip" : "xxxxx1" }...
IUnknown's user avatar
  • 9,635

15 30 50 per page
1
2 3 4 5
14