|
@@ -21,6 +21,7 @@ package org.elasticsearch.search.aggregations.support;
|
|
|
import org.apache.lucene.util.BytesRef;
|
|
|
import org.elasticsearch.common.Nullable;
|
|
|
import org.elasticsearch.common.geo.GeoPoint;
|
|
|
+import org.elasticsearch.common.joda.Joda;
|
|
|
import org.elasticsearch.index.fielddata.IndexFieldData;
|
|
|
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
|
|
|
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
|
|
@@ -53,7 +54,7 @@ public class ValuesSourceConfig<VS extends ValuesSource> {
|
|
|
if (field == null) {
|
|
|
if (script == null) {
|
|
|
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(ValuesSourceType.ANY);
|
|
|
- config.format(resolveFormat(null, valueType));
|
|
|
+ config.format(resolveFormat(null, valueType, timeZone));
|
|
|
return config;
|
|
|
}
|
|
|
ValuesSourceType valuesSourceType = valueType != null ? valueType.getValuesSourceType() : ValuesSourceType.ANY;
|
|
@@ -67,7 +68,7 @@ public class ValuesSourceConfig<VS extends ValuesSource> {
|
|
|
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);
|
|
|
config.missing(missing);
|
|
|
config.timezone(timeZone);
|
|
|
- config.format(resolveFormat(format, valueType));
|
|
|
+ config.format(resolveFormat(format, valueType, timeZone));
|
|
|
config.script(createScript(script, context));
|
|
|
config.scriptValueType(valueType);
|
|
|
return config;
|
|
@@ -79,7 +80,7 @@ public class ValuesSourceConfig<VS extends ValuesSource> {
|
|
|
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);
|
|
|
config.missing(missing);
|
|
|
config.timezone(timeZone);
|
|
|
- config.format(resolveFormat(format, valueType));
|
|
|
+ config.format(resolveFormat(format, valueType, timeZone));
|
|
|
config.unmapped(true);
|
|
|
if (valueType != null) {
|
|
|
// todo do we really need this for unmapped?
|
|
@@ -120,7 +121,7 @@ public class ValuesSourceConfig<VS extends ValuesSource> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static DocValueFormat resolveFormat(@Nullable String format, @Nullable ValueType valueType) {
|
|
|
+ private static DocValueFormat resolveFormat(@Nullable String format, @Nullable ValueType valueType, @Nullable DateTimeZone tz) {
|
|
|
if (valueType == null) {
|
|
|
return DocValueFormat.RAW; // we can't figure it out
|
|
|
}
|
|
@@ -128,6 +129,9 @@ public class ValuesSourceConfig<VS extends ValuesSource> {
|
|
|
if (valueFormat instanceof DocValueFormat.Decimal && format != null) {
|
|
|
valueFormat = new DocValueFormat.Decimal(format);
|
|
|
}
|
|
|
+ if (valueFormat instanceof DocValueFormat.DateTime && format != null) {
|
|
|
+ valueFormat = new DocValueFormat.DateTime(Joda.forPattern(format), tz != null ? tz : DateTimeZone.UTC);
|
|
|
+ }
|
|
|
return valueFormat;
|
|
|
}
|
|
|
|