title: MongoDB Java use multiple filters and get last
body: <p>In my collection the documents look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/0OHYM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0OHYM.png" alt="enter image description here"></a></p>
  
  <p>I've managed to get the last inserted document by doing this:</p>
  
  <pre><code>collection.find().sort(new Document("date",-1)).first().getDate()
  </code></pre>
  
  <p>But now I need to get the last by date AND that has got a specific value for <code>functionalityName</code>. I'm stuck because I don't know how to modify it to take in consideration both filters. How do I do that?<br>
  I had a look at multiple filters in Mongo but since I'm not looking for a specific date but for the greater one (last one), I don't know how to specify that together with other filters.</p>