title: How to get paginated/sliced data of subdocument array in mongo collection?
body: <p>I have a collection like this:</p>
  
  <pre><code>{
  "_id" : ObjectId("51f4ad560364f5490ccebe26"),
  "fiTpcs" : [
      "uuid1",
      "uuid2",
      "uuid3",
      "uuid4",
      "uuid5"
  ],
  "fiTpcsCnt" : 5
  }
  </code></pre>
  
  <p>The list of fiTpcs is long and can go to hundreds later. When I retrieve my collection, I want to get a limited list of fiTpcs, say 20 at a time and fire separate requests to get subsequent data from fiTpcs. I just want to ensure that the queries don't get slow later when I have a lot more data. Is there a way to do it in mongodb? until now, I have been doing    </p>
  
  <pre><code>db.userext.find({"_id" : ObjectId("51f4ad560364f5490ccebe26")}).pretty();
  </code></pre>
  
  <p>which always gets me the full fiTpcs array. I am using java driver with Spring and a solution using Spring/java would also be fine. Please note - if the solution requires mongo to scan through the whole fiTpcs array and then slice a part of it, it doesn't really add any performance benefits, that is not what I am looking for.</p>