title: MongoDB query in Spring repository: limit number of records after filter
body: <p>I have the following query (with hard-coded parameters for simplicity) , using the "@Query" annotation within a Spring repository:</p>
  
  <p>@Query("{$query : {status:'Failed'}, $maxScan: 10}")</p>
  
  <p>The intent of this query is to read the first 10 records from the database that have a status of "Failed" (the records are system jobs).  However, the query will first read 10 records, then read records with a status of "Failed" from those 10 records.</p>
  
  <p>I need to apply the limit to a resultset after the filter is applied, not before.  How can I modify the above query to return the first 10 records of the resultset that is read after the filter logic is applied, i.e. the first 10 records with a status of "Failed"?</p>
  
  <p>Thanks in advance.</p>