title: Distinct in Spring Data MongoDB
body: <p>Has anyone tried incorporating <code>distinct</code> in their query using <code>Spring Data for Mongo</code>. If you have an example can you please post it. Where and how should I include the <code>distinct flag</code>?</p>
  
  <p><a href="http://docs.spring.io/spring-data/data-mongo/docs/1.3.1.RELEASE/reference/html/repositories.html" rel="noreferrer">Link to the Spring Data Mongo example</a> -- <code>Example 4.4. Query creation from method names</code></p>
  
  <pre><code>// Enables the distinct flag for the query
  List&lt;Person&gt; findDistinctPeopleByLastnameOrFirstname(String lastname, String firstname);
  List&lt;Person&gt; findPeopleDistinctByLastnameOrFirstname(String lastname, String firstname);
  </code></pre>