Skip to content

Tag: mongodb

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 $pro…

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 rea…

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 POJ…

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 S…