title: Create index on a converted sub document field with Spring Data MongoDB
body: <p>Using Spring Data for Mongo (any recent version) I'm trying to set an index on a field that is persisted as a sub-document through the help of a <code>org.springframework.core.convert.converter.Converter</code> (it is actually two fields)</p>
  <p>My document class looks like this:</p>
  <pre><code>@Document
  class Doc {
    @Indexed
    private MySuperField superField;
  
    // id, getter setter ignored
  }
  </code></pre>
  <p>While my document structure in database looks like this:</p>
  <pre><code>{
    &quot;superField&quot;: {
       &quot;field1&quot;: 123,
       &quot;field2&quot;: 456
    }
  }
  </code></pre>
  <p>The index gets created on <code>superField</code> - while I would like it to be on <code>superField.field1</code>. of course from Spring's point of view it is logical - only the <code>Converter</code> has any notion of the sub document.</p>
  <p>Is there any way to position the index on the right field while still using annotations? Otherwise I'll have to use a mongo template to explicitely create it...</p>
  <p>Note : the actual use case behind this is to store a ZonedDateTime without loosing the original timezone information. First field is epoch, second is original timezone.</p>
  <p><strong>EDIT</strong> : I need to set expiration time of the index. Which makes compound indices irrelevant sadly.</p>