Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ public boolean enableRewriteToFilterByFilter() {
return true;
}

@Override
public boolean isInSortOrderExecutionRequired() {
return false;
}

@Override
public void close() {
List<Releasable> releaseMe = new ArrayList<>(this.releaseMe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
import org.elasticsearch.search.aggregations.pipeline.ParsedStatsBucket;
import org.elasticsearch.search.aggregations.pipeline.PercentilesBucketPipelineAggregationBuilder;
import org.elasticsearch.search.aggregations.pipeline.StatsBucketPipelineAggregationBuilder;
import org.elasticsearch.search.aggregations.timeseries.ParsedTimeSeries;
import org.elasticsearch.search.aggregations.timeseries.TimeSeriesAggregationBuilder;
import org.elasticsearch.search.suggest.Suggest;
import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder;
Expand Down Expand Up @@ -2893,6 +2895,7 @@ static List<NamedXContentRegistry.Entry> getDefaultNamedXContents() {
map.put(StringStatsAggregationBuilder.NAME, (p, c) -> ParsedStringStats.PARSER.parse(p, (String) c));
map.put(TopMetricsAggregationBuilder.NAME, (p, c) -> ParsedTopMetrics.PARSER.parse(p, (String) c));
map.put(InferencePipelineAggregationBuilder.NAME, (p, c) -> ParsedInference.fromXContent(p, (String) (c)));
map.put(TimeSeriesAggregationBuilder.NAME, (p, c) -> ParsedTimeSeries.fromXContent(p, (String) (c)));
List<NamedXContentRegistry.Entry> entries = map.entrySet()
.stream()
.map(entry -> new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(entry.getKey()), entry.getValue()))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
setup:
- skip:
version: " - 8.1.0"
reason: Suipport for time_series aggs was added in 8.1.0

- do:
indices.create:
index: tsdb
body:
settings:
number_of_replicas: 0
mode: time_series
routing_path: [key]
time_series:
start_time: "2021-01-01T00:00:00Z"
end_time: "2022-01-01T00:00:00Z"
mappings:
properties:
key:
type: keyword
time_series_dimension: true
"@timestamp":
type: date

- do:
cluster.health:
wait_for_status: green

- do:
bulk:
index: tsdb
refresh: true
body:
- '{ "index": {} }'
- '{ "key": "bar", "val": 2, "@timestamp": "2021-01-01T00:00:10Z" }'
- '{ "index": {}}'
- '{ "key": "bar", "val": 10, "@timestamp": "2021-01-01T00:00:00Z" }'
- '{ "index": {}}'
- '{ "key": "bar", "val": 50, "@timestamp": "2021-01-01T00:00:30Z" }'
- '{ "index": {}}'
- '{ "key": "bar", "val": 40, "@timestamp": "2021-01-01T00:00:20Z" }'

# Let's try to create another segment to make things a bit more interesting
- do:
bulk:
index: tsdb
refresh: true
body:
- '{ "index": {} }'
- '{ "key": "foo", "val": 20, "@timestamp": "2021-01-01T00:00:00Z" }'
- '{ "create": {} }'
- '{ "key": "foo", "val": 30, "@timestamp": "2021-01-01T00:10:00Z" }'
- '{ "index": {} }'
- '{ "key": "baz", "val": 20, "@timestamp": "2021-01-01T00:00:00Z" }'
- '{ "index": {} }'
- '{ "key": "baz", "val": 20, "@timestamp": "2021-01-01T00:00:00" }'

---
"Basic test":
- do:
search:
index: tsdb
body:
query:
range:
"@timestamp":
gte: "2021-01-01T00:10:00Z"
size: 0
aggs:
ts:
time_series:
keyed: false



- match: { hits.total.value: 1 }
- length: { aggregations.ts.buckets: 1 }

- match: { aggregations.ts.buckets.0.key: { "key": "foo" } }
- match: { aggregations.ts.buckets.0.doc_count: 1 }

Loading