I am using Spring Data Elasticsearch 2.0.1 with Elastic version 2.2.0.
My DAO is similar to:
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
@Document(indexName = "myIndex")
public class MyDao {
@Id
private String id;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
<other fields, setters, getters omitted>
}
Saving the object to ES using a repository the _id
metadata field gets populated correctly. The getter and setter methods for the id
field correctly return the value of the _id
metadata field. But the id field within the _source
field is null.
2 questions: 1) Why is the id field null? 2) Does it matter that the id field is null?