Skip to content
Advertisement

Tag: mongodb

Mongo DB Aggregation with Count for Specific Conditions and filter by Date Range which Outputs a Projection Doesn’t work as Expected

Please consider that I’m a beginner to MongoDB and I need to retrieve data from MongoDB database in somewhat complex query format. I’ve referred several Questions and Answers published in the community but my expected query was much complex due to some complex counts operations for certain conditions etc. However I was able manage to retrieve the data to a

How to initialize an empty Mono Class object in reactive programming?

I am learning reactive and I wanted to know how to initialize a Mono object, like in Java when:User usr=new User(). How to create a Mono object of this similar class? Answer There are different ways you can create an object. Checkout this link for better understanding https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html Here you can just use the Mono.just(new User());

MongoDB Aggregation Pipeline – Count no of records that are matching a complex criteria – (Couldn’t find PersistentEntity for type java.lang.Object!)

I have documents with dynamic fields and I would need to find a count of matching records for a given complex query criteria Example Entity Example Data: Expected Query Criteria: Building such complex Criteria using $match would be too much of implementation, so I was trying to use SPEL evolution through $project like below: However, the above logic failing due

How to use a JSON file to aggregate in MongoDB in Java?

I am using the Java MongoDB driver v4.3: I have my aggregation pipelines written in JSON files which are placed in the src/main/resources folder. The aggregate function only accepts a List<Bson>. After fetching the file, how do I pass it into the MongoDB method? Answer This is how you do it:

mongo toLIst() java.lang.OutOfMemoryError: Java heap space

I try to fetch some data from mongodb , but my k8s pods hitting: Checking the heap dump this seems is causing some trouble: In general, it creates an iterator using Mongo driver streaming API and iterates through all annotations returned by a database using given criteria. It seems that Mongo DB driver is reading annotations in bulks of 47427

Mongodb Java SDK not using the @BsonProperty as the field name

I am using the mongodb-driver-sync library, version: 4.2.3 in my Java project to insert values into a MongoDB collection. When I insert them, the field names are not the values in the @BsonProperty annotation but the lower camel case of the Java variable names. How do I make it use my annonation value? My POJO is: My insertion code is:

In the MongoDB java driver, will methods produce an error if the optional `ClientSession` is null?

I’ve been creating an abstraction of the MongoDB java driver. Given the following block of code… Where session can be either null or an actual instance of ClientSession. Will I run into issues with this paradigm? I have many methods like this, including col.replaceOne(), col.deleteOne, col.countDocuments(), etc. Answer According to the MongoDB Repository, passing in a null ClientSession will throw

Spring boot aggregation with group Trim

Consider collection with whitespace in field, in DB if there is white space if we group them “Ravi”, ” Ravi ” , consider as total 2 values. but it should consider as single value. So I have trim in Group. I had performed in DB. But I don’t know how can I trim and group value in Springboot. We can

Advertisement