Using the @Id
annotation, I can add an id
field to my model object and when the query is executed, the resulting model object will contain the elasticsearch _id
in the annotated @Id
field.
However, I have yet to figure out how to get other document metadata, such as _version
. I tried to add the version
field to my model and annotate 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 mean fields like _index
, _type
, _id
, _version
, etc.
I am particularly concerned about _version
because it is used for optimistic locking.
It seems to me that if _id
supported, then _version
and other metadata fields should also be supported.
I just read the spring -data-elasticsearch docs and I can't find anything. If anyone knows, please let me know.
Are all metadata fields of an elasticsearch document supported in spring-data-elasticsearch? If so, how?
Also, if I can somehow get _version
, then how can I use it to optimize the lock when using spring -data-elasticsearch?
Thanks.