title: Automatically generate numerical id when using ElasticSearch with Spring Data
body: <p>I am currently converting a project I did from Spring Data with Hibernate to Spring Data with ElasticSearch.</p>
  
  <p>Before, I was able to auto generate the id of my entity using the annotation <code>@GeneratedValue(strategy = GenerationType.IDENTITY)</code>.  This way, when the entity is saved, an id number is generated for it.</p>
  
  <p>However, I can't seem to find an annotation that ElasticSearch uses to achieve the same result.</p>
  
  <p>The entity using Hibernate annotation:</p>
  
  <pre><code>@Entity
  @Table(name = "person")
  public class Person {
  
      @Id
      @Column(name = "id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private long id;
  
      @Column(name = "name")
      private String name;
  
      @Column(name = "age")
      private int age;
  
      public long getId() {
          return id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
      public Person() {
      }
  
      public Person(String name, int age) {
          this.name = name;
          this.age = age;
      }
  
      @Override
      public String toString() {
          return "Person [id=" + id + ", name=" + name + ", age=" + age + "]";
      }
  </code></pre>
  
  <p>Is there an ElasticSearch equivalent to the @GeneratedValue annotation?  If not, what is the optimal way to populate the id field when using ElasticSearch?</p>