spring-data-mongodb

Spring Data MongoDB Slow MongoTemplate.find() Performance

青春壹個敷衍的年華 提交于 2021-02-09 09:57:38
问题 I'm having performance issues when querying ~12,000 user documents, indexed by 1 column, (companyId), no other filter. The whole collection only has ~27000. It took me about 12 seconds to get the ~12000 rows of data... I tried running explain for this query: db.instoreMember.find({companyId:"5b6be3e2096abd567974f924"}).explain(); result follows: { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "production.instoreMember", "indexFilterSet" : false, "parsedQuery" : { "companyId" : { "$eq

Spring Data MongoDB Slow MongoTemplate.find() Performance

China☆狼群 提交于 2021-02-09 09:57:12
问题 I'm having performance issues when querying ~12,000 user documents, indexed by 1 column, (companyId), no other filter. The whole collection only has ~27000. It took me about 12 seconds to get the ~12000 rows of data... I tried running explain for this query: db.instoreMember.find({companyId:"5b6be3e2096abd567974f924"}).explain(); result follows: { "queryPlanner" : { "plannerVersion" : 1, "namespace" : "production.instoreMember", "indexFilterSet" : false, "parsedQuery" : { "companyId" : { "$eq

Update only specific sub document deep in nested array of array of documents [duplicate]

流过昼夜 提交于 2021-02-08 10:50:49
问题 This question already has answers here : Updating a Nested Array with MongoDB (2 answers) How to use updateOption with arrayFilters in spring-data mongodb? (2 answers) Update field in exact element array in MongoDB (3 answers) Closed 1 year ago . I have a sample document which has nested arrays like below. { "locations" : [ { "appointments" : [ { "apptId" : "3456", "status" : "" }, { "apptId" : "12345", "status" : "" } ] }, { "appointments" : [ { "apptId" : "12345", "status" : "" }, { "apptId

Update only specific sub document deep in nested array of array of documents [duplicate]

不羁岁月 提交于 2021-02-08 10:48:26
问题 This question already has answers here : Updating a Nested Array with MongoDB (2 answers) How to use updateOption with arrayFilters in spring-data mongodb? (2 answers) Update field in exact element array in MongoDB (3 answers) Closed 1 year ago . I have a sample document which has nested arrays like below. { "locations" : [ { "appointments" : [ { "apptId" : "3456", "status" : "" }, { "apptId" : "12345", "status" : "" } ] }, { "appointments" : [ { "apptId" : "12345", "status" : "" }, { "apptId

How to Flatten dynamic field with parent document - Spring data Mongo DB

巧了我就是萌 提交于 2021-02-08 08:26:22
问题 In my Spring boot project have a Document like so: @Document(collection="AuditTable") public class AuditTable { @Id private String id; private Map<String, String> properties; where properties is a dynamic field i.e. it can take in as many different key-value pairs. I use MongoRepository to store this value: @Repository public interface AuditTableRepo extends MongoRepository<AuditTable, String> { } Now when I store it in the Collection it looks like this: whereas I want it to look like this: "

Specifing a Sharded Collection with Spring Data MongoDB

夙愿已清 提交于 2021-02-07 18:09:05
问题 I am using Spring Boot and Spring Data MongoDB to interface with an underlying sharded MongoDB cluster. My Spring Boot Application access the cluster via a mongos router. Using Spring Data MongoDB, you can specify the collection an object is persisted to via @Document(collection = "nameOfCollection") , or it defaults to the class name (first letter lowercase). These collections do not need to exist before-hand; they can be created at runtime. To shard a collection in MongoDB, you need to 1 -

Specifing a Sharded Collection with Spring Data MongoDB

余生长醉 提交于 2021-02-07 18:02:03
问题 I am using Spring Boot and Spring Data MongoDB to interface with an underlying sharded MongoDB cluster. My Spring Boot Application access the cluster via a mongos router. Using Spring Data MongoDB, you can specify the collection an object is persisted to via @Document(collection = "nameOfCollection") , or it defaults to the class name (first letter lowercase). These collections do not need to exist before-hand; they can be created at runtime. To shard a collection in MongoDB, you need to 1 -

Find Distinct Embedded Document and further make distinct using Field

扶醉桌前 提交于 2021-02-07 10:34:43
问题 I'm using Spring Boot Mongo example. I went through many links like: I want result with distinct value of one field from mongodb using spring data, but still did not get any break through. I am using below code: List<Object> obj = mongoTemplate.query(Health.class).distinct("healths").all(); List<Health> healths = null; if (!CollectionUtils.isEmpty(obj)) { healths = obj.stream().map(e -> (Health) e).collect(Collectors.toList()); } With this code I am getting duplicate HealthCode=E , Is there

How to log the queries executed by Spring Data MongoDB?

孤街醉人 提交于 2021-02-04 05:42:09
问题 Is there a way to find the query that was run against the database in spring data mongodb? I know this is possible in case of JPA. So was just wondering if there was something similar in Spring data MongoDB? 回答1: The easiest way is to set the log level to DEBUG for org.springframework.data.mongodb . 回答2: logging: level: org.springframework.data.mongodb.core.MongoTemplate: DEBUG To clarify Oliver's answer add that to the application.yml file or properties file. 来源: https://stackoverflow.com

How to log the queries executed by Spring Data MongoDB?

拈花ヽ惹草 提交于 2021-02-04 05:41:30
问题 Is there a way to find the query that was run against the database in spring data mongodb? I know this is possible in case of JPA. So was just wondering if there was something similar in Spring data MongoDB? 回答1: The easiest way is to set the log level to DEBUG for org.springframework.data.mongodb . 回答2: logging: level: org.springframework.data.mongodb.core.MongoTemplate: DEBUG To clarify Oliver's answer add that to the application.yml file or properties file. 来源: https://stackoverflow.com