Last active
June 26, 2018 03:03
-
-
Save vanga/25676b40a248f7b99f7e03d5d51a2b59 to your computer and use it in GitHub Desktop.
This file contains 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
{ | |
"size": 0, | |
"query": { | |
"bool": {} | |
}, | |
"aggregations": { | |
"sum_agg": { | |
"filters": { | |
"filters": { | |
"123": { | |
"match_all": {} | |
} | |
} | |
}, | |
"aggs": { | |
"agg_func_1": { | |
"stats": { | |
"script": { | |
"inline": "def func_1_1; def func_1_2; def func_1; func_1 = 0d; def func_1_args = ['values': [], 'count': 0]; if (!(doc[params.func_1_1_field].empty)) { func_1_1 = doc[params.func_1_1_field].value; } if (params.func_1_2 != null) { func_1_2 = params.func_1_2} else {func_1_2 = -12} if (func_1_1 != null) {func_1_args.values.add(func_1_1); func_1_args.count++} if (func_1_2 != null) {func_1_args.values.add(func_1_2); func_1_args.count++} if (func_1_args.count > 0) { func_1_args.sum = 0d; for (func_1_args_val in func_1_args.values) { if (func_1_args_val != null) {func_1_args.sum += func_1_args_val ;}} func_1 = func_1_args.sum ;} func_1 ", | |
"params": { | |
"func_1_1_field": "sales", | |
"func_1_2": -12 | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment