Java 如何在Spring Boot中使用特定的日期范围和聚合从MongoDB数据库检索数据?

Java 如何在Spring Boot中使用特定的日期范围和聚合从MongoDB数据库检索数据?,java,mongodb,spring-boot,microservices,aggregation,Java,Mongodb,Spring Boot,Microservices,Aggregation,我正在从事一个spring启动项目,并使用MongoDB作为我的数据库 studentDB数据库包含一个学生文档,该文档包含以下字段: _id、学生姓名、参加讲座、iso dom、iso dow、iso月、iso年、iso周” 学生文件 _id Object student_name String attend_lecture int iso_dom int date of the month ("1" January

我正在从事一个spring启动项目,并使用MongoDB作为我的数据库

studentDB数据库包含一个学生文档,该文档包含以下字段:

_id、学生姓名、参加讲座、iso dom、iso dow、iso月、iso年、iso周”

学生文件

   _id             Object
   student_name    String
   attend_lecture  int
   iso_dom         int    date of the month ("1" January 2015)
   iso_dow         int    day of the week (Friday)
   iso_month       int    the month (1 stand for January)
   iso_year        int    year (2015)
   iso_week        int    week number (1)
  "_id":"5c1639b3a1b32bb04547137f",

  "student_name":"MR. Rahul"

  "iso_dom":12,

  "iso_dow":3,

  "iso_month":1,

  "iso_week":12,

  "isp_year":2018,

  "attend_lecture":5
在这里,我试图检索2015年1月12日至2015年3月13日期间有多少学生参加了讲座

我尝试过的方法:

  • 我在MongoDB中使用了包含小于和大于子句的聚合

  • 在检索2015年1月12日至2015年3月13日之间的所有日期时,我还使用了部分条款的日期

  • 问题: 有没有可行的方法来检索2015年1月12日至2015年3月13日期间参加讲座的学生人数

    示例:

    学生文件

       _id             Object
       student_name    String
       attend_lecture  int
       iso_dom         int    date of the month ("1" January 2015)
       iso_dow         int    day of the week (Friday)
       iso_month       int    the month (1 stand for January)
       iso_year        int    year (2015)
       iso_week        int    week number (1)
    
      "_id":"5c1639b3a1b32bb04547137f",
    
      "student_name":"MR. Rahul"
    
      "iso_dom":12,
    
      "iso_dow":3,
    
      "iso_month":1,
    
      "iso_week":12,
    
      "isp_year":2018,
    
      "attend_lecture":5
    

    插入新的关键日期,该日期提供选择两个日期之间的文档的选项,并使用聚合函数检索2015年1月12日至2015年3月13日期间的上课人数