title: Spring Data MongoDB index declaration for field of field
body: <p>I have the following Spring Data MongoDB document:</p>
  
  <pre><code>@Document(collection = "messages")
  @CompoundIndexes({ @CompoundIndex(name = "chatId_messageId", def = "{'chatId': 1, 'messageId': 1}") })
  public class Message implements Serializable {
  
      private static final long serialVersionUID = -1590112217771926691L;
  
      @Id
      private String id;
  
      private Long chatId;
  
      private Integer messageId;
  
      private Post post;
  
  }
  </code></pre>
  
  <p>the <code>Post</code> model(<strong>which is not Spring Data MongoDB document</strong>) looks like:</p>
  
  <pre><code>public class Post implements Serializable {
  
      private static final long serialVersionUID = -886664249197573502L;
  
      private String id;
  
  }
  </code></pre>
  
  <p>I'd like to add index to the <code>Message.post.id</code> field.</p>
  
  <p>How it can be done with Spring Data MongoDB and <code>Message.post</code> field declaration in <code>Message</code> document ?</p>