title: Group by time interval spring-data-mongo
body: <p>Below is my document structure:</p>
  
  <pre><code>{
     "_id":"5c59c35d8610f702d00e6f70",
     "stationId":"2",
     "listenerId":"807",
     "streamId":"37",
     "userAgentId":"7",
     "botDefinitionId":"18",
     "ipAddress":"50.116.14.48",
     "startTime":"2018-02-06T12:51:59.000Z",
     "endTime":"2018-02-06T12:53:56.000Z",
     "listenLength":"117",
     "totalDataUsed":"1433582",
  }
  </code></pre>
  
  <p>Using spring data mongo I would like to group these into windows of time (lets say 15 min intervals). I have created the following working query:</p>
  
  <pre><code>{
     '_id':{
        'year':{
           '$year':'$startTime'
        },
        'week':{
           '$week':'$startTime'
        },
        'dayOfMonth':{
           '$dayOfMonth':'$startTime'
        },
        'month':{
           '$month':'$startTime'
        },
        'hour':{
           '$hour':'$startTime'
        },
        'interval':{
           '$subtract':[
              {
                 '$minute':'$startTime'
              },
              {
                 '$mod':[
                    {
                       '$minute':'$startTime'
                    },
                    15
                 ]
              }
           ]
        }
     },
     'count':{
        '$sum':1
     }
  }
  </code></pre>
  
  <p>Which then returns me the following document:</p>
  
  <pre><code>_id:{
     year:2018   week:15   dayOfMonth:18   month:4   hour:18   interval:45
  },
  count:9
  </code></pre>
  
  <p>How do I use the <a href="https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/aggregation/GroupOperation.html" rel="nofollow noreferrer">GroupOperation</a> to specify form this aggregation in spring-data-mongo?</p>