title: How to query the same field twice using the Mongo Repository?
body: <p>So i want to make a query that looks for all tasks existing in my collection, with the criteria of having a date attribute between two given dates.
  I have used the Between keyword, but it's not including the values of the parameters in results.<br>
  For example if the parameters are 2019-09-20 and 2019-09-25, the tasks that are planned for those same dates won't be returned in the response.</p>
  
  <p>I have tried to use LessThanEqual and GreaterThanEqual, but i get the following error :    </p>
  
  <pre><code>org.springframework.data.mongodb.InvalidMongoDbApiUsageException: Due to limitations of the com.mongodb.BasicDocument, you can't add a second 'task.date' expression specified as 'task.date : Document{{$lte=Thu Sep 26 00:00:00 CEST 2019}}'. Criteria already contains 'task.date : Document{{$gte=Wed Sep 25 00:00:00 CEST 2019}}'.
  
  </code></pre>
  
  <p>And that's why i want to know if there's a way to query twice on the same field.</p>
  
  <p>This is my repository.</p>
  
  <pre><code>public interface TaskRepository extends MongoRepository&lt;TaskEntry, String&gt; {
      List&lt;TaskEntry&gt; findByTask_DateGreaterThanEqualAndTask_DateLessThanEqual(Date dateFrom, Date dateTo);
  }
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE :</strong><br>
  This is an illustrating example of my collection, query and the result after using rustyx's answer.<br>
  These are my documents : </p>
  
  <pre><code>[
      {
          "id": "5c3da5b163c2789768d1402a",
          "code": "0000001",
          "createdDate": "2019-01-15T09:19:45.114+0000",
          "lastModifiedDate": "2019-01-15T09:19:45.114+0000",
          "task": {
              "codeRule": null,
              "title": "Task 1",
              "date": "2019-09-26T00:00:00.000+0000",
              "description": "This is the first task",
              "type": "UNITARY",
              "result": null
          }
      },
      {
          "id": "5c3da7dc63c2789768d1402b",
          "code": "0000002",
          "createdDate": "2019-01-15T09:29:00.125+0000",
          "lastModifiedDate": "2019-01-15T09:29:00.125+0000",
          "task": {
              "codeRule": null,
              "title": "Task 2",
              "date": "2019-09-26T00:00:00.000+0000",
              "description": "This is the second task",
              "type": "UNITARY",
              "result": null
          }
      },
      {
          "id": "5c3db0c763c27868b41e022b",
          "code": "0000003",
          "createdDate": "2019-01-15T10:07:03.693+0000",
          "lastModifiedDate": "2019-01-15T10:07:03.693+0000",
          "task": {
              "codeRule": null,
              "title": "Task 3",
              "date": "2019-09-28T00:00:00.000+0000",
              "description": "This is the third task",
              "type": "UNITARY",
              "result": null
          }
      }
  ]
  </code></pre>
  
  <p>And this is the response i get by using this: </p>
  
  <pre><code>@Query("{'task.date': {$gte: ?0, $lte:?1 }}")
      List&lt;TaskEntry&gt; findByTask_DateBetween(Date dateFrom, Date dateTo);
  </code></pre>
  
  <p>And this : </p>
  
  <pre><code>/tasks?dateFrom=2019-09-26&amp;dateTo=2019-09-28
  </code></pre>
  
  <p>Response :    </p>
  
  <pre><code>[
      {
          "id": "5c3da5b163c2789768d1402a",
          "code": "0000001",
          "createdDate": "2019-01-15T09:19:45.114+0000",
          "lastModifiedDate": "2019-01-15T09:19:45.114+0000",
          "task": {
              "codeRule": null,
              "title": "Task 1",
              "date": "2019-09-26T00:00:00.000+0000",
              "description": "This is the first task",
              "type": "UNITARY",
              "result": null
          }
      },
      {
          "id": "5c3da7dc63c2789768d1402b",
          "code": "0000002",
          "createdDate": "2019-01-15T09:29:00.125+0000",
          "lastModifiedDate": "2019-01-15T09:29:00.125+0000",
          "task": {
              "codeRule": null,
              "title": "Task 2",
              "date": "2019-09-26T00:00:00.000+0000",
              "description": "This is the second task",
              "type": "UNITARY",
              "result": null
          }
      }
  ]
  </code></pre>
  
  <p>The tasks with date 2019-09-26 are being added to respone which means <strong>$gte: ?0</strong> is working, but the task with date 2019-09-28 in not there.</p>