title: Spring data mongoDB: Get the distinct rows with pagination
body: <p>I have User class like,</p>
  
  <pre><code>@Document(collection = "users")
  
  public class User {
  
      private String id;
      private String firstName;
      private String lastName;
      private String jobTitle;
      private String email;
      private String phoneNumber;
  }
  </code></pre>
  
  <p>And UserDimension as,</p>
  
  <pre><code>@Document(collection = "userDimensions")
  
  public class UserDimension{
  
      private String id;
      private String userId;
  
      private String dimensionId;
  
      private String status;
  }
  </code></pre>
  
  <p>I want the userDimension records from mongoDB based on distinct userId with pagination in spring data mongoDB ?</p>
  
  <p>I am using the query like,</p>
  
  <pre><code>Query query = new Query();
  
  List&lt;UserDimension&gt; userDimensionList = null;
  
  // apply pagination parameters to the search criteria
  query.with(pageable);
  userDimensionList = mongoTemplate.getCollection("userDimensions").distinct("userId", query.getQueryObject());
  </code></pre>
  
  <p>But it still giving me the total records.</p>