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

Using @Version gives error - version_type parameter value must be lowercase #9

Closed
ausov opened this issue Sep 16, 2016 · 12 comments
Closed
Assignees
Labels
Milestone

Comments

@ausov
Copy link

ausov commented Sep 16, 2016

Elasticsearch expects version_type parameter value to be lowercase (case-sensitive), i.e. it should be "external", not EXTERNAL. Gives error with ES 2.3 (and 2.4). Tested with AWS ES service and standalone.

Given:

@Document(indexName = "version-test")
public class MyDoc {
  ...
  @Version
  private Long version = 0L;
}

When: saving to index (using an ElasticsearchRepository)

Then:

2016-09-16 03:45:18.451 ERROR 68586 --- [           main] c.g.v.s.jest.JestElasticsearchTemplate   : Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"illegal_argument_exception","reason":"No version type match [EXTERNAL]"}],"type":"illegal_argument_exception","reason":"No version type match [EXTERNAL]"} , message : null
2016-09-16 03:45:18.485 ERROR 68586 --- [           main] o.s.d.r.w.RepositoryRestExceptionHandler : Query can not be null.

Suggestion: see JestElasticsearchTemplate.java Line 1165 - convert to lowercase string (or use ordinal).

            if (query.getVersion() != null) {
                indexBuilder.setParameter(Parameters.VERSION, query.getVersion());
                indexBuilder.setParameter(Parameters.VERSION_TYPE, EXTERNAL);
            }
@VanRoy VanRoy added the bug label Sep 16, 2016
@VanRoy VanRoy added this to the 2.1.1 milestone Sep 16, 2016
@VanRoy VanRoy self-assigned this Sep 16, 2016
@VanRoy
Copy link
Owner

VanRoy commented Sep 16, 2016

Hi @ausov ,

I will integrate the fix in the next minor release.

Thanks for your feedback.
Julien.

@VanRoy
Copy link
Owner

VanRoy commented Sep 16, 2016

@ausov , this fix is on master.

Can you try the 2.1.1-SNAPSHOT and validate the fix on your env ?

Thanks.

@ausov
Copy link
Author

ausov commented Sep 16, 2016

Yes, the current master works on my env now with Spring Boot 1.4 + ES 2.4 (embedded). Thank you!

@ausov
Copy link
Author

ausov commented Sep 16, 2016

Related question or an issue. How can I use internal versioning of Elasticsearch together with Spring Data Rest? In order to benefit from the built-in mechanism, I have to use @Version annotation but this leads to external versioning in the current impl.

Suggestion: Would it be better to introduce a new (optional) annotation to specify a version type, e.g. @VersionType(EXTERNAL) or @VersionField(type=EXTERNAL) to use together with @Version. For example:

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

We can then expose the repo using @RepositoryRestResource and it will provide out-of-the box the ETag headers and related stuff. What do you think?

@VanRoy
Copy link
Owner

VanRoy commented Sep 18, 2016

@ausov ,

It's a good idea. But at this time, I try to keep spring-data-jest more close as possible to spring-data-elasticsearch. I will evaluation the possiblity to add this feature anyway.

Can you open a new Issue an spring-data-elasticsearch with your idea ?
And can you open a new issue ( label enhancement ) on this project to keep you idea in safe.

I will close this issue at the release 2.1.1

Thanks a lot for you feedback and your help.
Julien.

@VanRoy VanRoy closed this as completed Sep 18, 2016
@ausov
Copy link
Author

ausov commented Sep 18, 2016

OK, thanks again! Created #11 for future enhancements and a new issue in spring-data-elasticsearch.

@ruchichhabra009
Copy link

Hi Van,

For my project I need to run scripts in Elastic Search and AWS doesn't support Scripts below elastic search version 5.XXX. I am trying to use 5+ version with Jest it is giving me error. Any suggestion will be appreciated.
(Not an option to use other cloud service) I am trying to see if there is quickfix for elastic search 5.xxx.

Thanks

@VanRoy
Copy link
Owner

VanRoy commented Oct 10, 2017

Hi Van, can you send me more information about your issue ?
Is it exactly the same bug ? Is it related to version_type ?

@ruchichhabra009
Copy link

Hi Van,

Thank you for your response, I am getting errors:

I tried with 3 versions - 5.2,5.5 and 5.6 and got the following error: But this is working fine with 2.3 version.

Elastic Search 5.5 and 5.6.2

HttpMediaTypeNotAcceptableException: Could not find acceptable representation spring
  | Cannot execute jest action , response code : 401 , error : {"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/metadata/feedSourceInfo/_count]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}}],"type":"security_exception","reason":"missing authentication token for REST request [/metadata/feedSourceInfo/_count]","header":{"WWW-Authenticate":"Basic realm="security" charset="UTF-8""}} ,

Elastic Search 5.2
Cannot execute jest action , response code : 400 , error : {"root_cause":[{"type":"illegal_argument_exception","reason":"request [/metadata/_refresh] contains unrecognized parameter: [refresh]"}],"type":"illegal_argument_exception","reason":"request [/metadata/_refresh] contains unrecognized parameter: [refresh]"} , message : null

@ruchichhabra009
Copy link

@VanRoy Please let me know if there is any update coming up which support Elastic 5.x version with Jest.

Thanks
Ruchi

@VanRoy
Copy link
Owner

VanRoy commented Oct 10, 2017

@ruchichhabra009 , can you tell me which version of SpringDataJest do you use ?
The 3.0.0 is validated with ES 5.5.

@ruchichhabra009
Copy link

Thanks @VanRoy I think I missed your upgrade. I will test my system now. If it works.

Thanks
Ruchi

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

No branches or pull requests

3 participants