Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to use an internal type of @Version provided by Elasticsearch #11

Open
ausov opened this issue Sep 18, 2016 · 1 comment
Open
Assignees

Comments

@ausov
Copy link

ausov commented Sep 18, 2016

How can we use internal versioning of Elasticsearch?

Elsticsearch has a possibility to use internal (managed by ES) or external (managed in code) types of version to implement optimistic locking (https://www.elastic.co/blog/elasticsearch-versioning-support). Currently, if an entity field marked with @org.springframework.data.annotation.Version the external version type is always used.

On the other hand, the Spring Data Rest also uses @Version mechanism to implement ETag and If-Match headers handling. This means that if we want to use this mechanism, we're forced to use ES optimistic locking and external ES versioning.

So, it would be great if we can specify which version mechanism we want to use. Note, same issue is with the spring-data-elasticsearch.

Possible solution: Introduce a new optional annotation on a version field or, probably more appropriate, on a repository to specify a version type, e.g. @VersionType(EXTERNAL). For example:

@VersionType(EXTERNAL)
@Version
private Long version = 0L;
...

or on repository class:

@VersionType(EXTERNAL)
public class MyRepo extends ElasticsearchReporitory ...

Workaround: implement a custom repo taking care of version increment.

@ausov
Copy link
Author

ausov commented Sep 18, 2016

Added issue in spring-data-elasticsearch: https://jira.spring.io/browse/DATAES-295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants