org.elasticsearch.index.mapper.TimeSeriesParams Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch subproject :server
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.index.mapper;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.function.Function;
/**
* Utility functions for time series related mapper parameters
*/
public final class TimeSeriesParams {
public static final String TIME_SERIES_METRIC_PARAM = "time_series_metric";
public static final String TIME_SERIES_DIMENSION_PARAM = "time_series_dimension";
private TimeSeriesParams() {}
public enum MetricType {
gauge(new String[] { "max", "min", "value_count", "sum" }),
counter(new String[] { "last_value" }),
histogram(new String[] { "value_count" }), // TODO Add more aggs
summary(new String[] { "value_count", "sum", "min", "max" });
private final String[] supportedAggs;
MetricType(String[] supportedAggs) {
this.supportedAggs = supportedAggs;
}
public String[] supportedAggs() {
return supportedAggs;
}
}
public static FieldMapper.Parameter metricParam(Function initializer, MetricType... values) {
assert values.length > 0;
EnumSet acceptedValues = EnumSet.noneOf(MetricType.class);
acceptedValues.addAll(Arrays.asList(values));
return FieldMapper.Parameter.restrictedEnumParam(
TIME_SERIES_METRIC_PARAM,
false,
initializer,
null,
MetricType.class,
acceptedValues
).acceptsNull();
}
public static FieldMapper.Parameter dimensionParam(Function initializer) {
return FieldMapper.Parameter.boolParam(TIME_SERIES_DIMENSION_PARAM, false, initializer, false);
}
}