Mongodb spring data group _id toLower or case insensetive

I have mongodb facet and aggregate query in spring boot using mongo template and aggregation query. everything works fine except case sensitivity of value. I have below query in mongodb: db.getCollection(‘product’).aggregate([{“colors”:[{$unwind:”$variants”}, {“$group”: { _id: { $toLower: “$variants.color” }, count:{$sum:1}, image : { $first: ‘$variants.color_image’ }, }} ] I have equivalent spring data query: Aggregation.facet(unwind(“variants”), group(“variants.color”).count().as(“count”).first(“variants.color_image”).as(“image”))…

MongoDB aggregating multiple arrays of objects based on shared key

I’m writing a query to calculate multiple metrics for each user in my DB. I’ve calculated all of the metrics, and have a structure like this { “metric1”: [{“user_id”: 1, “val”: 13},{“user_id”: 2, “val”: 100}], “metric2”: [{“user_id”: 2, “val”: 29},{“user_id”: 1, “val”: 123}], “metric3”: [{“user_id”: 1, “val”: 46},{“user_id”: 2, “val”: 111] } I’m trying to…

How to write a mongoDB query to match any element in an array of subdocuments against any element in a Typescipt Array?

I have a mongoDB database containing Events. Each event is defined by a number of fields, including an array of genres (which are subdocuments consisting of a {genre and subGenre}). For example: an event could be of {genre: “music”, subGenre: “jazz”}, and {genre: “music”, subGenre: “blues”}. See event.js – the model. In this case, 2…

How to store byte[] image in mongodb for Doocr process

Hi how to store byte image in mongodb Model: public class Photo { @Id private String id; private byte[] image; } getter & setter Controller: @Controller public class PhotoController { @GetMapping(“/photos/upload”) public String uploadPhoto(Model model) { model.addAttribute(“message”, “hello”); return “uploadPhoto”; } I am looking rest api based sample to store byte [] image in mongodb.…