-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Add a MovingFunction pipeline aggregation, deprecate MovingAvg agg #29594
Changes from 2 commits
775c436
8377899
8dbb601
9c9934a
c93d065
0988e82
a9d3be4
17b7408
635ca8f
43eee62
7747fab
08b915c
2b27b5d
121b31d
34346cc
a7cb005
505ee27
25a226a
a5393e6
e7b35cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Licensed to Elasticsearch under one or more contributor | ||
# license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright | ||
# ownership. Elasticsearch licenses this file to you under | ||
# the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
# This file contains a whitelist for the Moving Function pipeline aggregator in core | ||
|
||
class org.elasticsearch.search.aggregations.pipeline.movfn.MovingFunctions { | ||
double windowMax(Collection) | ||
double windowMin(Collection) | ||
double windowSum(Collection) | ||
double simpleMovAvg(Collection) | ||
double linearMovAvg(Collection) | ||
double ewmaMovAvg(Collection, double) | ||
double holtMovAvg(Collection, double, double) | ||
double holtWintersMovAvg(Collection, double, double, double, int, boolean) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Sanity integration test to make sure the custom context and whitelist work for moving_fn pipeline agg | ||
# | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
_doc: | ||
properties: | ||
value_field: | ||
type: integer | ||
date: | ||
type: date | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test | ||
_type: _doc | ||
_id: 1 | ||
- date: "2017-01-01T00:00:00" | ||
value_field: 1 | ||
- index: | ||
_index: test | ||
_type: _doc | ||
_id: 2 | ||
- date: "2017-01-02T00:00:00" | ||
value_field: 2 | ||
- index: | ||
_index: test | ||
_type: _doc | ||
_id: 3 | ||
- date: "2017-01-03T00:00:00" | ||
value_field: 3 | ||
- index: | ||
_index: test | ||
_type: _doc | ||
_id: 4 | ||
- date: "2017-01-04T00:00:00" | ||
value_field: 4 | ||
- index: | ||
_index: test | ||
_type: _doc | ||
_id: 5 | ||
- date: "2017-01-05T00:00:00" | ||
value_field: 5 | ||
- index: | ||
_index: test | ||
_type: _doc | ||
_id: 6 | ||
- date: "2017-01-06T00:00:00" | ||
value_field: 6 | ||
|
||
- do: | ||
indices.refresh: | ||
index: [test] | ||
|
||
--- | ||
"Basic test": | ||
|
||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
the_histo: | ||
date_histogram: | ||
field: "date" | ||
interval: "1d" | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: "value_field" | ||
the_mov_fn: | ||
moving_fn: | ||
buckets_path: "the_avg" | ||
window: 3 | ||
script: "MovingFunctions.windowMax(values)" | ||
|
||
- match: { hits.total: 6 } | ||
- length: { hits.hits: 0 } | ||
- is_false: aggregations.the_histo.buckets.0.the_mov_fn.value | ||
- match: { aggregations.the_histo.buckets.1.the_mov_fn.value: 1.0 } | ||
- match: { aggregations.the_histo.buckets.2.the_mov_fn.value: 2.0 } | ||
- match: { aggregations.the_histo.buckets.3.the_mov_fn.value: 3.0 } | ||
- match: { aggregations.the_histo.buckets.4.the_mov_fn.value: 4.0 } | ||
- match: { aggregations.the_histo.buckets.5.the_mov_fn.value: 5.0 } | ||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
"Bad window": | ||
|
||
- do: | ||
catch: /\[window\] must be a positive, non-zero integer\./ | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
the_histo: | ||
date_histogram: | ||
field: "date" | ||
interval: "1d" | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: "value_field" | ||
the_mov_fn: | ||
moving_fn: | ||
buckets_path: "the_avg" | ||
window: -1 | ||
script: "MovingFunctions.windowMax(values)" | ||
|
||
--- | ||
"Not under date_histo": | ||
|
||
- do: | ||
catch: /\[window\] must be a positive, non-zero integer\./ | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: "value_field" | ||
the_mov_fn: | ||
moving_fn: | ||
buckets_path: "the_avg" | ||
window: -1 | ||
script: "MovingFunctions.windowMax(values)" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ public enum GapPolicy { | |
* GapPolicy in string format (e.g. "ignore") | ||
* @return GapPolicy enum | ||
*/ | ||
public static GapPolicy parse(String text, XContentLocation tokenLocation) { | ||
public static GapPolicy parse(String text) { | ||
GapPolicy result = null; | ||
for (GapPolicy policy : values()) { | ||
if (policy.parseField.match(text, LoggingDeprecationHandler.INSTANCE)) { | ||
|
@@ -79,7 +79,7 @@ public static GapPolicy parse(String text, XContentLocation tokenLocation) { | |
for (GapPolicy policy : values()) { | ||
validNames.add(policy.getName()); | ||
} | ||
throw new ParsingException(tokenLocation, "Invalid gap policy: [" + text + "], accepted values: " + validNames); | ||
throw new IllegalArgumentException("Invalid gap policy: [" + text + "], accepted values: " + validNames); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we removing the token location here, it seems like useful information to return to the user? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it was incompatible with the new parser style (I didnt think you could get token info with the new way of writing parsers), but while writing this comment I noticed how BucketSort did it:
which I somehow missed before. I'll put it back to the way it was and using the above snippet :) |
||
} | ||
return result; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should test that the other functions are exposed correctly too?