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

Update by Query is modified to accept short script parameter. #26841

Merged
merged 3 commits into from
Oct 11, 2017

Conversation

pozhidaevak
Copy link
Contributor

This change adding support of both long and short form of script parameter to _update_by_query request.
It should close the issue #24898 .

Changes in code:
static function RestUpdateByQueryAction:parseScript() is modified to accept Object parameter.
If Object is an instance of Map then it is a long form of script and old version of this function will be executed.
If Object is an instance of String then Script object will be created by using Script(String) constructor.

All tests are passed or ignored. However, gradle check is failed with the next message (I think it is not connected with my changes * What went wrong:
Execution failed for task ':docs:integTestCluster#installAnalysisIcuPlugin'.

A problem occurred starting process 'command '/Users/anton/Private/Coding/elasticsearch/docs/build/cluster/integTestCluster node0/elasticsearch-7.0.0-alpha1-SNAPSHOT/bin/elasticsearch-plugin''
`

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor requests for changes but it looks good to me! Thanks for doing this and I'm sorry for leading you astray with my mistaken comments earlier.

assert config != null : "Script should not be null";

if (config instanceof String) {
return new Script((String) config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the indentation on this to line up?

return new Script(type, lang, script, params);
return new Script(type, lang, script, params);
}
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually don't put a newline between } and else. Can you undo?

@nik9000
Copy link
Member

nik9000 commented Oct 10, 2017

@elasticmachine, test this please.

@nik9000
Copy link
Member

nik9000 commented Oct 10, 2017

Can you add a test for this? I'd add it to qa/smoke-test-reindex-with-all-modules/src/test/resources/rest-api-spec/test/reindex/update_by_query/10_script.yml.

@pozhidaevak
Copy link
Contributor Author

@nik9000, thanks for comments.
I'll fix mistakes, add tests and commit it to this branch

@pozhidaevak
Copy link
Contributor Author

I created a test and tried to launch it, but I it's not executing. So, I've created a topic on elastic forum with description of the error

@pozhidaevak
Copy link
Contributor Author

@nik9000, Thanks for help with testing. I pushed formatting changes and a new test

@nik9000 nik9000 merged commit cee9640 into elastic:master Oct 11, 2017
@nik9000
Copy link
Member

nik9000 commented Oct 11, 2017

Thanks @pozhidaevak! I've merged to master and will cherry-pick into 6.x and push that after the tests pass for me locally.

I didn't think to ask you before, but would you like to write the documentation update for this? This page is generated by docs/reference/doc/update-by-query.asciidoc. The instructions for building the docs are here or you can just make the change blind and I'll check it if you submit a PR. All the snippets in the docs are checked as part of the build. So if you add a snippet you can test that it works with gradle docs:check. That'll test all the snippets in the docs but that only takes a few minutes. If your snippet fails it'll print out reproduction steps you can use to rerun just that snippet.

nik9000 pushed a commit that referenced this pull request Oct 11, 2017
Update by Query is modified to accept short `script` parameter.

Closes issue #24898
@pozhidaevak
Copy link
Contributor Author

@nik9000, yah, I’ll add a documentation. Do I need to mention full version from which short form of script is accepted by API? If so, what is the version?

@nik9000
Copy link
Member

nik9000 commented Oct 12, 2017

@pozhidaevak you don't need to mention the version in the docs because I'll only backport your documentation change only to the branches that have the change. When the targeted version is released we'll flip "current" version of the docs to the version with your change. Folks that browse older versions of the docs won't get docs for your change.

The targeted version for this is 6.1/7.0. The master branch that you developed it against is 7.0 and the 6.x branch that I backported it to is planned to be 6.1.

jasontedor added a commit that referenced this pull request Oct 12, 2017
* master: (35 commits)
  Create weights lazily in filter and filters aggregation (#26983)
  Use a dedicated ThreadGroup in rest sniffer (#26897)
  Fire global checkpoint sync under system context
  Update by Query is modified to accept short `script` parameter. (#26841)
  Cat shards bytes (#26952)
  Add support for parsing inline script (#23824) (#26846)
  Change default value to true for transpositions parameter of fuzzy query (#26901)
  Adding unreleased 5.6.4 version number to Version.java
  Rename TCPTransportTests to TcpTransportTests (#26954)
  Fix NPE for /_cat/indices when no primary shard (#26953)
  [DOCS] Fixed indentation of the definition list.
  Fix formatting in channel close test
  Check for closed connection while opening
  Clarify systemd overrides
  [DOCS] Plugin Installation for Windows (#21671)
  Painless: add tests for cached boxing (#24163)
  Don't detect source's XContentType in DocumentParser.parseDocument() (#26880)
  Fix handling of paths containing parentheses
  Allow only a fixed-size receive predictor (#26165)
  Add Homebrew instructions to getting started
  ...
jasontedor added a commit that referenced this pull request Oct 12, 2017
* 6.x: (32 commits)
  Use a dedicated ThreadGroup in rest sniffer (#26897)
  Fire global checkpoint sync under system context
  Update by Query is modified to accept short `script` parameter. (#26841)
  Cat shards bytes (#26952)
  Adding unreleased 5.6.4 version number to Version.java
  Rename TCPTransportTests to TcpTransportTests (#26954)
  Fix NPE for /_cat/indices when no primary shard (#26953)
  [DOCS] Fixed indentation of the definition list.
  Check for closed connection while opening
  Clarify systemd overrides
  [DOCS] Plugin Installation for Windows (#21671)
  Painless: add tests for cached boxing (#24163)
  Don't detect source's XContentType in DocumentParser.parseDocument() (#26880)
  Return List instead of an array from settings (#26903)
  Emit deprecation warning for variable size predictor
  Fix handling of paths containing parentheses
  Deprecate variable-size receive predictor
  Add Homebrew instructions to getting started
  ingest: Fix bug that prevent date_index_name processor from accepting timestamps specified as a json number
  Scripting: Fix expressions to temporarily support filter scripts (#26824)
  ...
@pozhidaevak
Copy link
Contributor Author

@nik9000, thanks for explaining.
I also think it will be useful to update docs/reference/modules/scripting/using.asciidoc.

I think I've found an inconsistency between code and documentation in the code we have painless as the default language. From Script.java:

public static final String DEFAULT_SCRIPT_LANG = "painless";
//some code is omitted

// this constructor is used to create simple script
public Script(String idOrCode) {
        this(DEFAULT_SCRIPT_TYPE, DEFAULT_SCRIPT_LANG, idOrCode, Collections.emptyMap(), Collections.emptyMap());
    } 

But in the documentation it is stated (from using.asciidoc):

The default language may be changed in the elasticsearch.yml config file by
setting script.default_lang to the appropriate language.

However, it needs to be checked by running some tests...

@rjernst
Copy link
Member

rjernst commented Oct 12, 2017

script.default_lang was removed back in 5.0. So those docs are just leftover and should be removed.

jasontedor added a commit to olcbean/elasticsearch that referenced this pull request Oct 16, 2017
* master: (356 commits)
  Do not set SO_LINGER on server channels (elastic#26997)
  Fix inconsistencies in the rest api specs for *_script (elastic#26971)
  fix inconsistencies in the rest api specs for cat.snapshots (elastic#26996)
  Add docs on full_id parameter in cat nodes API
  [TEST] Add test that replicates versioned updates with random flushes
  Use internal searcher for all indexing related operations in the engine
  Reformat paragraph in template docs to 80 columns
  Clarify settings and template on create index
  Fix reference to TcpTransport in documentation
  Allow Uid#decodeId to decode from a byte array slice (elastic#26987)
  Fix a typo in the similarity docs (elastic#26970)
  Use separate searchers for "search visibility" vs "move indexing buffer to disk (elastic#26972)
  Create weights lazily in filter and filters aggregation (elastic#26983)
  Use a dedicated ThreadGroup in rest sniffer (elastic#26897)
  Fire global checkpoint sync under system context
  Update by Query is modified to accept short `script` parameter. (elastic#26841)
  Cat shards bytes (elastic#26952)
  Add support for parsing inline script (elastic#23824) (elastic#26846)
  Change default value to true for transpositions parameter of fuzzy query (elastic#26901)
  Adding unreleased 5.6.4 version number to Version.java
  ...
@lcawl lcawl added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. and removed :Reindex API labels Feb 13, 2018
@colings86 colings86 removed the v7.0.0 label Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. >enhancement v6.1.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants