title: How to use spring data mongo @CompoundIndex with sub collections?
body: <p>Assume that I have such entities like the following:</p>
  
  <pre><code>@Document(collection = "doc_a")
  public class A {    
    @Field("id")
    private Integer id;
  
    @Field("b")
    private Collection&lt;B&gt; b;
    ...
  }
  
  
  public class B {    
    @Field("id")
    private Integer id;
    ...
  }
  </code></pre>
  
  <p>is it possible to use a compoundIndex with respect to A.id AND B.id together?</p>
  
  <p>I mean maybe like:</p>
  
  <pre><code>@CompoundIndex(name = "aid_bid_idx", def = "{'id', 'b.id'}")
  </code></pre>
  
  <p>Thanks in advance.</p>