Using the @Id
annotation I can add an id
field to my model object and when I execute a query the resulting model object will contain the value of the elasticsearch _id
in the @Id
annotated field.
However, I have yet to figure out how to get other document meta-data such as the _version
. I tried adding a version
field to my model and annotating it with the @Version
annotation but nothing happened and the field remained null
.
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_version" : 1,
"found": true,
"_source" : {
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}
}
I'm referring to the fields such as _index
, _type
, _id
, _version
etc...
I'm especially concerned with _version
because that is used for optimistic locking.
It seems to me that if _id
is supported then _version
and the other meta-data fields should be supported somehow too.
I've just read the spring-data-elasticsearch docs and I can't find anything. If someone knows, please advise.
Are all of the elasticsearch document meta-data fields supported in spring-data-elasticsearch? If so, how?
Further, if I can get the _version
somehow then how can I use it for optimistic locking when using spring-data-elasticsearch?
Thanks.