Created
August 21, 2017 10:42
-
-
Save ryanorz/9b1a7bbb35152f59abdcba2a1a823f99 to your computer and use it in GitHub Desktop.
datafile of using_script_in_elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "script" : { | |
| "lang": "painless", | |
| "inline" : " | |
| for (def key : params.keySet()) { | |
| if (key == \"ctx\") | |
| continue; | |
| if (key == \"array1\") { | |
| for (int i = 0; i < params.array1.size(); i++) { | |
| for (int j = 0; j < ctx._source.array1.size(); j++) { | |
| if (ctx._source.array1[j].name == params.array1[i].name) { | |
| ctx._source.array1[j] = params.array1[i]; | |
| break; | |
| } else if (j == ctx._source.array1.size()-1) { | |
| ctx._source.array1.add(params.array1[i]); | |
| } | |
| } | |
| } | |
| continue; | |
| } | |
| ctx._source[key] = params[key]; | |
| } | |
| ", | |
| "params" : { | |
| "key1" : "value1", | |
| "key2" : "value2", | |
| "array1" : [{ | |
| "name" : "xxxx", | |
| "version" : "xxxxxx", | |
| "company" : "xxxxxx" | |
| }] | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment