parent
a2e44a0c76
commit
e50f514092
|
@ -54,7 +54,6 @@ import org.elasticsearch.index.mapper.NumberFieldMapper.Defaults;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -282,11 +281,6 @@ public class ScaledFloatFieldMapper extends FieldMapper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.NUMERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object valueForDisplay(Object value) {
|
public Object valueForDisplay(Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -506,6 +500,11 @@ public class ScaledFloatFieldMapper extends FieldMapper {
|
||||||
return scaledFieldData.getFieldName();
|
return scaledFieldData.getFieldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return scaledFieldData.getValuesSourceType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafNumericFieldData load(LeafReaderContext context) {
|
public LeafNumericFieldData load(LeafReaderContext context) {
|
||||||
return new ScaledFloatLeafFieldData(scaledFieldData.load(context), scalingFactor);
|
return new ScaledFloatLeafFieldData(scaledFieldData.load(context), scalingFactor);
|
||||||
|
|
|
@ -42,8 +42,7 @@ import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ChildrenAggregationBuilder
|
public class ChildrenAggregationBuilder extends ValuesSourceAggregationBuilder<ChildrenAggregationBuilder> {
|
||||||
extends ValuesSourceAggregationBuilder<ChildrenAggregationBuilder> {
|
|
||||||
|
|
||||||
public static final String NAME = "children";
|
public static final String NAME = "children";
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.StringFieldType;
|
import org.elasticsearch.index.mapper.StringFieldType;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -97,12 +96,7 @@ public class MetaJoinFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder();
|
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.StringFieldType;
|
import org.elasticsearch.index.mapper.StringFieldType;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -115,12 +114,7 @@ public final class ParentIdFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder();
|
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,7 +45,6 @@ import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.StringFieldType;
|
import org.elasticsearch.index.mapper.StringFieldType;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -233,12 +232,7 @@ public final class ParentJoinFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder();
|
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.query.TermQueryBuilder;
|
import org.elasticsearch.index.query.TermQueryBuilder;
|
||||||
import org.elasticsearch.mock.orig.Mockito;
|
import org.elasticsearch.mock.orig.Mockito;
|
||||||
import org.elasticsearch.search.SearchModule;
|
import org.elasticsearch.search.SearchModule;
|
||||||
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -94,7 +95,7 @@ public class QueryBuilderStoreTests extends ESTestCase {
|
||||||
when(queryShardContext.getWriteableRegistry()).thenReturn(writableRegistry());
|
when(queryShardContext.getWriteableRegistry()).thenReturn(writableRegistry());
|
||||||
when(queryShardContext.getXContentRegistry()).thenReturn(xContentRegistry());
|
when(queryShardContext.getXContentRegistry()).thenReturn(xContentRegistry());
|
||||||
when(queryShardContext.getForField(fieldMapper.fieldType()))
|
when(queryShardContext.getForField(fieldMapper.fieldType()))
|
||||||
.thenReturn(new BytesBinaryIndexFieldData(new Index("index", "uuid"), fieldMapper.name()));
|
.thenReturn(new BytesBinaryIndexFieldData(new Index("index", "uuid"), fieldMapper.name(), CoreValuesSourceType.BYTES));
|
||||||
when(queryShardContext.fieldMapper(Mockito.anyString())).thenAnswer(invocation -> {
|
when(queryShardContext.fieldMapper(Mockito.anyString())).thenAnswer(invocation -> {
|
||||||
final String fieldName = (String) invocation.getArguments()[0];
|
final String fieldName = (String) invocation.getArguments()[0];
|
||||||
KeywordFieldMapper.KeywordFieldType ft = new KeywordFieldMapper.KeywordFieldType();
|
KeywordFieldMapper.KeywordFieldType ft = new KeywordFieldMapper.KeywordFieldType();
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -127,12 +126,7 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder();
|
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,8 +38,6 @@ import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.TypeParsers;
|
import org.elasticsearch.index.mapper.TypeParsers;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.query.QueryShardException;
|
import org.elasticsearch.index.query.QueryShardException;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -125,11 +123,6 @@ public class Murmur3FieldMapper extends FieldMapper {
|
||||||
return new SortedNumericIndexFieldData.Builder(NumericType.LONG);
|
return new SortedNumericIndexFieldData.Builder(NumericType.LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.NUMERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query existsQuery(QueryShardContext context) {
|
public Query existsQuery(QueryShardContext context) {
|
||||||
return new DocValuesFieldExistsQuery(name());
|
return new DocValuesFieldExistsQuery(name());
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.NestedSortBuilder;
|
import org.elasticsearch.search.sort.NestedSortBuilder;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
@ -61,6 +62,12 @@ public interface IndexFieldData<FD extends LeafFieldData> extends IndexComponent
|
||||||
*/
|
*/
|
||||||
String getFieldName();
|
String getFieldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ValuesSourceType of the underlying data. It's possible for fields that use the same IndexFieldData implementation to have
|
||||||
|
* different ValuesSourceTypes, such as in the case of Longs and Dates.
|
||||||
|
*/
|
||||||
|
ValuesSourceType getValuesSourceType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the atomic field data for the reader, possibly cached.
|
* Loads the atomic field data for the reader, possibly cached.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.fielddata;
|
||||||
|
|
||||||
|
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specialization of {@link IndexFieldData} for histograms.
|
* Specialization of {@link IndexFieldData} for histograms.
|
||||||
|
@ -28,10 +29,12 @@ import org.elasticsearch.index.Index;
|
||||||
public abstract class IndexHistogramFieldData implements IndexFieldData<LeafHistogramFieldData> {
|
public abstract class IndexHistogramFieldData implements IndexFieldData<LeafHistogramFieldData> {
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public IndexHistogramFieldData(Index index, String fieldName) {
|
public IndexHistogramFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,6 +42,11 @@ public abstract class IndexHistogramFieldData implements IndexFieldData<LeafHist
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.function.LongUnaryOperator;
|
import java.util.function.LongUnaryOperator;
|
||||||
|
@ -46,28 +48,33 @@ public abstract class IndexNumericFieldData implements IndexFieldData<LeafNumeri
|
||||||
* The type of number.
|
* The type of number.
|
||||||
*/
|
*/
|
||||||
public enum NumericType {
|
public enum NumericType {
|
||||||
BOOLEAN(false, SortField.Type.LONG),
|
BOOLEAN(false, SortField.Type.LONG, CoreValuesSourceType.BOOLEAN),
|
||||||
BYTE(false, SortField.Type.LONG),
|
BYTE(false, SortField.Type.LONG, CoreValuesSourceType.NUMERIC),
|
||||||
SHORT(false, SortField.Type.LONG),
|
SHORT(false, SortField.Type.LONG, CoreValuesSourceType.NUMERIC),
|
||||||
INT(false, SortField.Type.LONG),
|
INT(false, SortField.Type.LONG, CoreValuesSourceType.NUMERIC),
|
||||||
LONG(false, SortField.Type.LONG),
|
LONG(false, SortField.Type.LONG, CoreValuesSourceType.NUMERIC),
|
||||||
DATE(false, SortField.Type.LONG),
|
DATE(false, SortField.Type.LONG, CoreValuesSourceType.DATE),
|
||||||
DATE_NANOSECONDS(false, SortField.Type.LONG),
|
DATE_NANOSECONDS(false, SortField.Type.LONG, CoreValuesSourceType.DATE),
|
||||||
HALF_FLOAT(true, SortField.Type.LONG),
|
HALF_FLOAT(true, SortField.Type.LONG, CoreValuesSourceType.NUMERIC),
|
||||||
FLOAT(true, SortField.Type.FLOAT),
|
FLOAT(true, SortField.Type.FLOAT, CoreValuesSourceType.NUMERIC),
|
||||||
DOUBLE(true, SortField.Type.DOUBLE);
|
DOUBLE(true, SortField.Type.DOUBLE, CoreValuesSourceType.NUMERIC);
|
||||||
|
|
||||||
private final boolean floatingPoint;
|
private final boolean floatingPoint;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
private final SortField.Type sortFieldType;
|
private final SortField.Type sortFieldType;
|
||||||
|
|
||||||
NumericType(boolean floatingPoint, SortField.Type sortFieldType) {
|
NumericType(boolean floatingPoint, SortField.Type sortFieldType, ValuesSourceType valuesSourceType) {
|
||||||
this.floatingPoint = floatingPoint;
|
this.floatingPoint = floatingPoint;
|
||||||
this.sortFieldType = sortFieldType;
|
this.sortFieldType = sortFieldType;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isFloatingPoint() {
|
public final boolean isFloatingPoint() {
|
||||||
return floatingPoint;
|
return floatingPoint;
|
||||||
}
|
}
|
||||||
|
public final ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -74,7 +74,7 @@ public enum GlobalOrdinalsBuilder {
|
||||||
new TimeValue(System.nanoTime() - startTimeNS, TimeUnit.NANOSECONDS)
|
new TimeValue(System.nanoTime() - startTimeNS, TimeUnit.NANOSECONDS)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new GlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldName(),
|
return new GlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldName(), indexFieldData.getValuesSourceType(),
|
||||||
atomicFD, ordinalMap, memorySizeInBytes, scriptFunction
|
atomicFD, ordinalMap, memorySizeInBytes, scriptFunction
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public enum GlobalOrdinalsBuilder {
|
||||||
subs[i] = atomicFD[i].getOrdinalsValues();
|
subs[i] = atomicFD[i].getOrdinalsValues();
|
||||||
}
|
}
|
||||||
final OrdinalMap ordinalMap = OrdinalMap.build(null, subs, PackedInts.DEFAULT);
|
final OrdinalMap ordinalMap = OrdinalMap.build(null, subs, PackedInts.DEFAULT);
|
||||||
return new GlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldName(),
|
return new GlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldName(), indexFieldData.getValuesSourceType(),
|
||||||
atomicFD, ordinalMap, 0, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION
|
atomicFD, ordinalMap, 0, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.index.fielddata.ScriptDocValues;
|
||||||
import org.elasticsearch.index.fielddata.plain.AbstractLeafOrdinalsFieldData;
|
import org.elasticsearch.index.fielddata.plain.AbstractLeafOrdinalsFieldData;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ import java.util.function.Function;
|
||||||
public final class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent implements IndexOrdinalsFieldData, Accountable {
|
public final class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent implements IndexOrdinalsFieldData, Accountable {
|
||||||
|
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
private final long memorySizeInBytes;
|
private final long memorySizeInBytes;
|
||||||
|
|
||||||
private final OrdinalMap ordinalMap;
|
private final OrdinalMap ordinalMap;
|
||||||
|
@ -65,12 +67,14 @@ public final class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent i
|
||||||
|
|
||||||
protected GlobalOrdinalsIndexFieldData(IndexSettings indexSettings,
|
protected GlobalOrdinalsIndexFieldData(IndexSettings indexSettings,
|
||||||
String fieldName,
|
String fieldName,
|
||||||
|
ValuesSourceType valuesSourceType,
|
||||||
LeafOrdinalsFieldData[] segmentAfd,
|
LeafOrdinalsFieldData[] segmentAfd,
|
||||||
OrdinalMap ordinalMap,
|
OrdinalMap ordinalMap,
|
||||||
long memorySizeInBytes,
|
long memorySizeInBytes,
|
||||||
Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction) {
|
Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction) {
|
||||||
super(indexSettings);
|
super(indexSettings);
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
this.memorySizeInBytes = memorySizeInBytes;
|
this.memorySizeInBytes = memorySizeInBytes;
|
||||||
this.ordinalMap = ordinalMap;
|
this.ordinalMap = ordinalMap;
|
||||||
this.segmentAfd = segmentAfd;
|
this.segmentAfd = segmentAfd;
|
||||||
|
@ -101,6 +105,11 @@ public final class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent i
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) {
|
public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) {
|
||||||
throw new UnsupportedOperationException("no global ordinals sorting yet");
|
throw new UnsupportedOperationException("no global ordinals sorting yet");
|
||||||
|
@ -191,6 +200,11 @@ public final class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent i
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) {
|
public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) {
|
||||||
throw new UnsupportedOperationException("no global ordinals sorting yet");
|
throw new UnsupportedOperationException("no global ordinals sorting yet");
|
||||||
|
|
|
@ -26,21 +26,29 @@ import org.apache.lucene.util.BytesRef;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.index.AbstractIndexComponent;
|
import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.fielddata.LeafFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||||
|
import org.elasticsearch.index.fielddata.LeafFieldData;
|
||||||
import org.elasticsearch.index.fielddata.RamAccountingTermsEnum;
|
import org.elasticsearch.index.fielddata.RamAccountingTermsEnum;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class AbstractIndexFieldData<FD extends LeafFieldData> extends AbstractIndexComponent implements IndexFieldData<FD> {
|
public abstract class AbstractIndexFieldData<FD extends LeafFieldData> extends AbstractIndexComponent implements IndexFieldData<FD> {
|
||||||
|
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
|
private ValuesSourceType valuesSourceType;
|
||||||
protected final IndexFieldDataCache cache;
|
protected final IndexFieldDataCache cache;
|
||||||
|
|
||||||
public AbstractIndexFieldData(IndexSettings indexSettings, String fieldName, IndexFieldDataCache cache) {
|
public AbstractIndexFieldData(
|
||||||
|
IndexSettings indexSettings,
|
||||||
|
String fieldName,
|
||||||
|
ValuesSourceType valuesSourceType,
|
||||||
|
IndexFieldDataCache cache
|
||||||
|
) {
|
||||||
super(indexSettings);
|
super(indexSettings);
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +57,11 @@ public abstract class AbstractIndexFieldData<FD extends LeafFieldData> extends A
|
||||||
return this.fieldName;
|
return this.fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
cache.clear(fieldName);
|
cache.clear(fieldName);
|
||||||
|
|
|
@ -28,12 +28,13 @@ import org.apache.lucene.index.TermsEnum;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||||
import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData;
|
import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData;
|
||||||
|
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
|
||||||
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsBuilder;
|
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsBuilder;
|
||||||
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData;
|
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -44,10 +45,17 @@ public abstract class AbstractIndexOrdinalsFieldData extends AbstractIndexFieldD
|
||||||
private final int minSegmentSize;
|
private final int minSegmentSize;
|
||||||
protected final CircuitBreakerService breakerService;
|
protected final CircuitBreakerService breakerService;
|
||||||
|
|
||||||
protected AbstractIndexOrdinalsFieldData(IndexSettings indexSettings, String fieldName,
|
protected AbstractIndexOrdinalsFieldData(
|
||||||
IndexFieldDataCache cache, CircuitBreakerService breakerService,
|
IndexSettings indexSettings,
|
||||||
double minFrequency, double maxFrequency, int minSegmentSize) {
|
String fieldName,
|
||||||
super(indexSettings, fieldName, cache);
|
ValuesSourceType valuesSourceType,
|
||||||
|
IndexFieldDataCache cache,
|
||||||
|
CircuitBreakerService breakerService,
|
||||||
|
double minFrequency,
|
||||||
|
double maxFrequency,
|
||||||
|
int minSegmentSize
|
||||||
|
) {
|
||||||
|
super(indexSettings, fieldName, valuesSourceType, cache);
|
||||||
this.breakerService = breakerService;
|
this.breakerService = breakerService;
|
||||||
this.minFrequency = minFrequency;
|
this.minFrequency = minFrequency;
|
||||||
this.maxFrequency = maxFrequency;
|
this.maxFrequency = maxFrequency;
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -45,10 +46,12 @@ public abstract class AbstractLatLonPointIndexFieldData implements IndexGeoPoint
|
||||||
|
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
AbstractLatLonPointIndexFieldData(Index index, String fieldName) {
|
AbstractLatLonPointIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,6 +59,11 @@ public abstract class AbstractLatLonPointIndexFieldData implements IndexGeoPoint
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
@ -79,8 +87,8 @@ public abstract class AbstractLatLonPointIndexFieldData implements IndexGeoPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LatLonPointIndexFieldData extends AbstractLatLonPointIndexFieldData {
|
public static class LatLonPointIndexFieldData extends AbstractLatLonPointIndexFieldData {
|
||||||
public LatLonPointIndexFieldData(Index index, String fieldName) {
|
public LatLonPointIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
super(index, fieldName);
|
super(index, fieldName, valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,11 +119,16 @@ public abstract class AbstractLatLonPointIndexFieldData implements IndexGeoPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
|
public Builder(ValuesSourceType valuesSourceType) {
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
// ignore breaker
|
// ignore breaker
|
||||||
return new LatLonPointIndexFieldData(indexSettings.getIndex(), fieldType.name());
|
return new LatLonPointIndexFieldData(indexSettings.getIndex(), fieldType.name(), valuesSourceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,19 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
public class BinaryIndexFieldData implements IndexFieldData<BinaryDVLeafFieldData> {
|
public class BinaryIndexFieldData implements IndexFieldData<BinaryDVLeafFieldData> {
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
|
public Builder(ValuesSourceType valuesSourceType) {
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryIndexFieldData build(
|
public BinaryIndexFieldData build(
|
||||||
IndexSettings indexSettings,
|
IndexSettings indexSettings,
|
||||||
|
@ -49,15 +56,17 @@ public class BinaryIndexFieldData implements IndexFieldData<BinaryDVLeafFieldDat
|
||||||
MapperService mapperService
|
MapperService mapperService
|
||||||
) {
|
) {
|
||||||
final String fieldName = fieldType.name();
|
final String fieldName = fieldType.name();
|
||||||
return new BinaryIndexFieldData(indexSettings.getIndex(), fieldName);
|
return new BinaryIndexFieldData(indexSettings.getIndex(), fieldName, valuesSourceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public BinaryIndexFieldData(Index index, String fieldName) {
|
public BinaryIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,6 +74,11 @@ public class BinaryIndexFieldData implements IndexFieldData<BinaryDVLeafFieldDat
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -43,10 +44,12 @@ public class BytesBinaryIndexFieldData implements IndexFieldData<BytesBinaryDVLe
|
||||||
|
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public BytesBinaryIndexFieldData(Index index, String fieldName) {
|
public BytesBinaryIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,6 +57,11 @@ public class BytesBinaryIndexFieldData implements IndexFieldData<BytesBinaryDVLe
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
@ -90,13 +98,18 @@ public class BytesBinaryIndexFieldData implements IndexFieldData<BytesBinaryDVLe
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
|
ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
|
public Builder(ValuesSourceType valuesSourceType) {
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
// Ignore breaker
|
// Ignore breaker
|
||||||
final String fieldName = fieldType.name();
|
final String fieldName = fieldType.name();
|
||||||
return new BytesBinaryIndexFieldData(indexSettings.getIndex(), fieldName);
|
return new BytesBinaryIndexFieldData(indexSettings.getIndex(), fieldName, valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.elasticsearch.index.mapper.TextFieldMapper;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -56,15 +57,17 @@ public class ConstantIndexFieldData extends AbstractIndexOrdinalsFieldData {
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
|
|
||||||
private final Function<MapperService, String> valueFunction;
|
private final Function<MapperService, String> valueFunction;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public Builder(Function<MapperService, String> valueFunction) {
|
public Builder(Function<MapperService, String> valueFunction, ValuesSourceType valuesSourceType) {
|
||||||
this.valueFunction = valueFunction;
|
this.valueFunction = valueFunction;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
return new ConstantIndexFieldData(indexSettings, fieldType.name(), valueFunction.apply(mapperService));
|
return new ConstantIndexFieldData(indexSettings, fieldType.name(), valueFunction.apply(mapperService), valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -136,8 +139,8 @@ public class ConstantIndexFieldData extends AbstractIndexOrdinalsFieldData {
|
||||||
|
|
||||||
private final ConstantLeafFieldData atomicFieldData;
|
private final ConstantLeafFieldData atomicFieldData;
|
||||||
|
|
||||||
private ConstantIndexFieldData(IndexSettings indexSettings, String name, String value) {
|
private ConstantIndexFieldData(IndexSettings indexSettings, String name, String value, ValuesSourceType valuesSourceType) {
|
||||||
super(indexSettings, name, null, null,
|
super(indexSettings, name, valuesSourceType, null, null,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
|
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
|
||||||
|
|
|
@ -35,12 +35,12 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.breaker.CircuitBreaker;
|
import org.elasticsearch.common.breaker.CircuitBreaker;
|
||||||
import org.elasticsearch.common.util.BigArrays;
|
import org.elasticsearch.common.util.BigArrays;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
|
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||||
import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData;
|
import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData;
|
||||||
|
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
|
||||||
import org.elasticsearch.index.fielddata.RamAccountingTermsEnum;
|
import org.elasticsearch.index.fielddata.RamAccountingTermsEnum;
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
|
||||||
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
||||||
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
|
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
|
||||||
import org.elasticsearch.index.fielddata.ordinals.OrdinalsBuilder;
|
import org.elasticsearch.index.fielddata.ordinals.OrdinalsBuilder;
|
||||||
|
@ -49,6 +49,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -61,25 +62,34 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData {
|
||||||
|
|
||||||
private final double minFrequency, maxFrequency;
|
private final double minFrequency, maxFrequency;
|
||||||
private final int minSegmentSize;
|
private final int minSegmentSize;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public Builder(double minFrequency, double maxFrequency, int minSegmentSize) {
|
public Builder(double minFrequency, double maxFrequency, int minSegmentSize, ValuesSourceType valuesSourceType) {
|
||||||
this.minFrequency = minFrequency;
|
this.minFrequency = minFrequency;
|
||||||
this.maxFrequency = maxFrequency;
|
this.maxFrequency = maxFrequency;
|
||||||
this.minSegmentSize = minSegmentSize;
|
this.minSegmentSize = minSegmentSize;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexOrdinalsFieldData build(IndexSettings indexSettings, MappedFieldType fieldType,
|
public IndexOrdinalsFieldData build(IndexSettings indexSettings, MappedFieldType fieldType,
|
||||||
IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
return new PagedBytesIndexFieldData(indexSettings, fieldType.name(), cache, breakerService,
|
return new PagedBytesIndexFieldData(indexSettings, fieldType.name(), valuesSourceType, cache, breakerService,
|
||||||
minFrequency, maxFrequency, minSegmentSize);
|
minFrequency, maxFrequency, minSegmentSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagedBytesIndexFieldData(IndexSettings indexSettings, String fieldName,
|
public PagedBytesIndexFieldData(
|
||||||
IndexFieldDataCache cache, CircuitBreakerService breakerService,
|
IndexSettings indexSettings,
|
||||||
double minFrequency, double maxFrequency, int minSegmentSize) {
|
String fieldName,
|
||||||
super(indexSettings, fieldName, cache, breakerService, minFrequency, maxFrequency, minSegmentSize);
|
ValuesSourceType valuesSourceType,
|
||||||
|
IndexFieldDataCache cache,
|
||||||
|
CircuitBreakerService breakerService,
|
||||||
|
double minFrequency,
|
||||||
|
double maxFrequency,
|
||||||
|
int minSegmentSize
|
||||||
|
) {
|
||||||
|
super(indexSettings, fieldName, valuesSourceType, cache, breakerService, minFrequency, maxFrequency, minSegmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.elasticsearch.index.mapper.MappedFieldType;
|
||||||
import org.elasticsearch.index.mapper.MapperService;
|
import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -79,11 +80,13 @@ public class SortedNumericIndexFieldData extends IndexNumericFieldData {
|
||||||
private final NumericType numericType;
|
private final NumericType numericType;
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public SortedNumericIndexFieldData(Index index, String fieldName, NumericType numericType) {
|
public SortedNumericIndexFieldData(Index index, String fieldName, NumericType numericType) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
this.numericType = Objects.requireNonNull(numericType);
|
this.numericType = Objects.requireNonNull(numericType);
|
||||||
|
this.valuesSourceType = numericType.getValuesSourceType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,6 +94,11 @@ public class SortedNumericIndexFieldData extends IndexNumericFieldData {
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -57,13 +58,15 @@ public class SortedSetOrdinalsIndexFieldData implements IndexOrdinalsFieldData {
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
private final Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction;
|
private final Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public Builder() {
|
public Builder(ValuesSourceType valuesSourceType) {
|
||||||
this(AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
this(AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION, valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder(Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction) {
|
public Builder(Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction, ValuesSourceType valuesSourceType) {
|
||||||
this.scriptFunction = scriptFunction;
|
this.scriptFunction = scriptFunction;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,7 +78,7 @@ public class SortedSetOrdinalsIndexFieldData implements IndexOrdinalsFieldData {
|
||||||
MapperService mapperService
|
MapperService mapperService
|
||||||
) {
|
) {
|
||||||
final String fieldName = fieldType.name();
|
final String fieldName = fieldType.name();
|
||||||
return new SortedSetOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction);
|
return new SortedSetOrdinalsIndexFieldData(indexSettings, cache, fieldName, valuesSourceType, breakerService, scriptFunction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,17 +88,20 @@ public class SortedSetOrdinalsIndexFieldData implements IndexOrdinalsFieldData {
|
||||||
private final IndexFieldDataCache cache;
|
private final IndexFieldDataCache cache;
|
||||||
private final CircuitBreakerService breakerService;
|
private final CircuitBreakerService breakerService;
|
||||||
private final Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction;
|
private final Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
private static final Logger logger = LogManager.getLogger(SortedSetOrdinalsIndexFieldData.class);
|
private static final Logger logger = LogManager.getLogger(SortedSetOrdinalsIndexFieldData.class);
|
||||||
|
|
||||||
public SortedSetOrdinalsIndexFieldData(
|
public SortedSetOrdinalsIndexFieldData(
|
||||||
IndexSettings indexSettings,
|
IndexSettings indexSettings,
|
||||||
IndexFieldDataCache cache,
|
IndexFieldDataCache cache,
|
||||||
String fieldName,
|
String fieldName,
|
||||||
|
ValuesSourceType valuesSourceType,
|
||||||
CircuitBreakerService breakerService,
|
CircuitBreakerService breakerService,
|
||||||
Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction
|
Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction
|
||||||
) {
|
) {
|
||||||
this.index = indexSettings.getIndex();
|
this.index = indexSettings.getIndex();
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
this.indexSettings = indexSettings;
|
this.indexSettings = indexSettings;
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.breakerService = breakerService;
|
this.breakerService = breakerService;
|
||||||
|
@ -107,6 +113,11 @@ public class SortedSetOrdinalsIndexFieldData implements IndexOrdinalsFieldData {
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
|
|
@ -40,7 +40,6 @@ import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.query.QueryShardException;
|
import org.elasticsearch.index.query.QueryShardException;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -134,12 +133,7 @@ public class BinaryFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new BytesBinaryIndexFieldData.Builder();
|
return new BytesBinaryIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,8 +39,6 @@ import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
|
||||||
import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -190,11 +188,6 @@ public class BooleanFieldMapper extends FieldMapper {
|
||||||
return new SortedNumericIndexFieldData.Builder(NumericType.BOOLEAN);
|
return new SortedNumericIndexFieldData.Builder(NumericType.BOOLEAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BOOLEAN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DocValueFormat docValueFormat(@Nullable String format, ZoneId timeZone) {
|
public DocValueFormat docValueFormat(@Nullable String format, ZoneId timeZone) {
|
||||||
if (format != null) {
|
if (format != null) {
|
||||||
|
|
|
@ -54,8 +54,6 @@ import org.elasticsearch.index.query.DateRangeIncludingNowQuery;
|
||||||
import org.elasticsearch.index.query.QueryRewriteContext;
|
import org.elasticsearch.index.query.QueryRewriteContext;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.DateTimeException;
|
import java.time.DateTimeException;
|
||||||
|
@ -534,11 +532,6 @@ public final class DateFieldMapper extends FieldMapper {
|
||||||
return new SortedNumericIndexFieldData.Builder(resolution.numericType());
|
return new SortedNumericIndexFieldData.Builder(resolution.numericType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.DATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object valueForDisplay(Object value) {
|
public Object valueForDisplay(Object value) {
|
||||||
Long val = (Long) value;
|
Long val = (Long) value;
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointIndexFieldData;
|
||||||
import org.elasticsearch.index.query.VectorGeoPointShapeQueryProcessor;
|
import org.elasticsearch.index.query.VectorGeoPointShapeQueryProcessor;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -192,13 +191,9 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<List<?
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new AbstractLatLonPointIndexFieldData.Builder();
|
return new AbstractLatLonPointIndexFieldData.Builder(CoreValuesSourceType.GEOPOINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.GEOPOINT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class ParsedGeoPoint extends GeoPoint implements ParsedPoint {
|
protected static class ParsedGeoPoint extends GeoPoint implements ParsedPoint {
|
||||||
|
|
|
@ -158,12 +158,6 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
return new TermInSetQuery(name(), bytesRefs);
|
return new TermInSetQuery(name(), bytesRefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
// TODO: should this even exist? Is aggregating on the ID field valid?
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
if (indexOptions() == IndexOptions.NONE) {
|
if (indexOptions() == IndexOptions.NONE) {
|
||||||
|
@ -172,7 +166,8 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
final IndexFieldData.Builder fieldDataBuilder = new PagedBytesIndexFieldData.Builder(
|
final IndexFieldData.Builder fieldDataBuilder = new PagedBytesIndexFieldData.Builder(
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
|
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE,
|
||||||
|
CoreValuesSourceType.BYTES);
|
||||||
return new IndexFieldData.Builder() {
|
return new IndexFieldData.Builder() {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
|
@ -197,6 +192,11 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
||||||
return fieldData.getFieldName();
|
return fieldData.getFieldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return fieldData.getValuesSourceType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafFieldData load(LeafReaderContext context) {
|
public LeafFieldData load(LeafReaderContext context) {
|
||||||
return wrap(fieldData.load(context));
|
return wrap(fieldData.load(context));
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
import org.elasticsearch.index.fielddata.plain.ConstantIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.ConstantIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -115,13 +114,9 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName);
|
return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName, CoreValuesSourceType.BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
private IndexFieldMapper(Settings indexSettings, MappedFieldType existing) {
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -292,12 +291,7 @@ public class IpFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder(IpScriptDocValues::new);
|
return new SortedSetOrdinalsIndexFieldData.Builder(IpScriptDocValues::new, CoreValuesSourceType.IP);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.IP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||||
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -261,12 +260,7 @@ public final class KeywordFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder();
|
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.query.QueryShardException;
|
import org.elasticsearch.index.query.QueryShardException;
|
||||||
import org.elasticsearch.index.similarity.SimilarityProvider;
|
import org.elasticsearch.index.similarity.SimilarityProvider;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -119,16 +118,6 @@ public abstract class MappedFieldType extends FieldType {
|
||||||
throw new IllegalArgumentException("Fielddata is not supported on field [" + name() + "] of type [" + typeName() + "]");
|
throw new IllegalArgumentException("Fielddata is not supported on field [" + name() + "] of type [" + typeName() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link ValuesSourceType} which supports this field type. This is tightly coupled to field data and aggregations support,
|
|
||||||
* so any implementation that returns a value from {@link MappedFieldType#fielddataBuilder} should also return a value from here.
|
|
||||||
*
|
|
||||||
* @return The appropriate {@link ValuesSourceType} for this field type.
|
|
||||||
*/
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
throw new IllegalArgumentException("Aggregations are not supported on field [" + name() + "] of type [" + typeName() + "]");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (!super.equals(o)) return false;
|
if (!super.equals(o)) return false;
|
||||||
|
|
|
@ -56,8 +56,6 @@ import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
|
||||||
import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -967,11 +965,6 @@ public class NumberFieldMapper extends FieldMapper {
|
||||||
return new SortedNumericIndexFieldData.Builder(type.numericType());
|
return new SortedNumericIndexFieldData.Builder(type.numericType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.NUMERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object valueForDisplay(Object value) {
|
public Object valueForDisplay(Object value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.elasticsearch.index.fielddata.plain.BinaryIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -239,12 +238,7 @@ public class RangeFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new BinaryIndexFieldData.Builder();
|
return new BinaryIndexFieldData.Builder(CoreValuesSourceType.RANGE);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.RANGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -37,8 +37,6 @@ import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData;
|
||||||
import org.elasticsearch.index.mapper.ParseContext.Document;
|
import org.elasticsearch.index.mapper.ParseContext.Document;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.seqno.SequenceNumbers;
|
import org.elasticsearch.index.seqno.SequenceNumbers;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -220,10 +218,6 @@ public class SeqNoFieldMapper extends MetadataFieldMapper {
|
||||||
return new SortedNumericIndexFieldData.Builder(NumericType.LONG);
|
return new SortedNumericIndexFieldData.Builder(NumericType.LONG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.NUMERIC;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SeqNoFieldMapper(Settings indexSettings) {
|
public SeqNoFieldMapper(Settings indexSettings) {
|
||||||
|
|
|
@ -69,7 +69,6 @@ import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData;
|
||||||
import org.elasticsearch.index.query.IntervalBuilder;
|
import org.elasticsearch.index.query.IntervalBuilder;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -772,13 +771,14 @@ public class TextFieldMapper extends FieldMapper {
|
||||||
+ "keyword field instead. Alternatively, set fielddata=true on [" + name() + "] in order to load "
|
+ "keyword field instead. Alternatively, set fielddata=true on [" + name() + "] in order to load "
|
||||||
+ "field data by uninverting the inverted index. Note that this can use significant memory.");
|
+ "field data by uninverting the inverted index. Note that this can use significant memory.");
|
||||||
}
|
}
|
||||||
return new PagedBytesIndexFieldData.Builder(fielddataMinFrequency, fielddataMaxFrequency, fielddataMinSegmentSize);
|
return new PagedBytesIndexFieldData.Builder(
|
||||||
|
fielddataMinFrequency,
|
||||||
|
fielddataMaxFrequency,
|
||||||
|
fielddataMinSegmentSize,
|
||||||
|
CoreValuesSourceType.BYTES
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int positionIncrementGap;
|
private int positionIncrementGap;
|
||||||
|
|
|
@ -46,7 +46,6 @@ import org.elasticsearch.index.fielddata.plain.ConstantIndexFieldData;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.index.query.support.QueryParsers;
|
import org.elasticsearch.index.query.support.QueryParsers;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -117,12 +116,7 @@ public class TypeFieldMapper extends MetadataFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
Function<MapperService, String> typeFunction = mapperService -> mapperService.documentMapper().type();
|
Function<MapperService, String> typeFunction = mapperService -> mapperService.documentMapper().type();
|
||||||
return new ConstantIndexFieldData.Builder(typeFunction);
|
return new ConstantIndexFieldData.Builder(typeFunction, CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class GeoHashGridAggregatorFactory extends ValuesSourceAggregatorFactory
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
||||||
.getAggregator(config.valueSourceType(), GeoHashGridAggregationBuilder.NAME);
|
.getAggregator(config, GeoHashGridAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof GeoGridAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof GeoGridAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected "
|
throw new AggregationExecutionException("Registry miss-match - expected "
|
||||||
+ GeoGridAggregatorSupplier.class.getName() + ", found [" + aggregatorSupplier.getClass().toString() + "]");
|
+ GeoGridAggregatorSupplier.class.getName() + ", found [" + aggregatorSupplier.getClass().toString() + "]");
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class GeoTileGridAggregatorFactory extends ValuesSourceAggregatorFactory
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
||||||
.getAggregator(config.valueSourceType(), GeoTileGridAggregationBuilder.NAME);
|
.getAggregator(config, GeoTileGridAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof GeoGridAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof GeoGridAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected "
|
throw new AggregationExecutionException("Registry miss-match - expected "
|
||||||
+ GeoGridAggregatorSupplier.class.getName() + ", found [" + aggregatorSupplier.getClass().toString() + "]");
|
+ GeoGridAggregatorSupplier.class.getName() + ", found [" + aggregatorSupplier.getClass().toString() + "]");
|
||||||
|
|
|
@ -72,7 +72,7 @@ public final class AutoDateHistogramAggregatorFactory extends ValuesSourceAggreg
|
||||||
if (collectsFromSingleBucket == false) {
|
if (collectsFromSingleBucket == false) {
|
||||||
return asMultiBucketAggregator(this, searchContext, parent);
|
return asMultiBucketAggregator(this, searchContext, parent);
|
||||||
}
|
}
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
AutoDateHistogramAggregationBuilder.NAME);
|
AutoDateHistogramAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof AutoDateHistogramAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof AutoDateHistogramAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected AutoDateHistogramAggregationSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected AutoDateHistogramAggregationSupplier, found [" +
|
||||||
|
|
|
@ -81,7 +81,7 @@ public final class DateHistogramAggregatorFactory extends ValuesSourceAggregator
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
DateHistogramAggregationBuilder.NAME);
|
DateHistogramAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof DateHistogramAggregationSupplier == false) {
|
if (aggregatorSupplier instanceof DateHistogramAggregationSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected DateHistogramAggregationSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected DateHistogramAggregationSupplier, found [" +
|
||||||
|
|
|
@ -92,7 +92,7 @@ public final class HistogramAggregatorFactory extends ValuesSourceAggregatorFact
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
HistogramAggregationBuilder.NAME);
|
HistogramAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof HistogramAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof HistogramAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected HistogramAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected HistogramAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -20,9 +20,11 @@
|
||||||
package org.elasticsearch.search.aggregations.bucket.missing;
|
package org.elasticsearch.search.aggregations.bucket.missing;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||||
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||||
|
@ -59,7 +61,15 @@ public class MissingAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
return new MissingAggregator(name, factories, valuesSource, searchContext, parent, metadata);
|
final AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
||||||
|
.getAggregator(config, MissingAggregationBuilder.NAME);
|
||||||
|
if (aggregatorSupplier instanceof MissingAggregatorSupplier == false) {
|
||||||
|
throw new AggregationExecutionException("Registry miss-match - expected MissingAggregatorSupplier, found [" +
|
||||||
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (MissingAggregator) ((MissingAggregatorSupplier) aggregatorSupplier)
|
||||||
|
.build(name, factories, valuesSource, searchContext, parent, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,8 @@ public class AbstractRangeAggregatorFactory<R extends Range> extends ValuesSourc
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
|
||||||
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
aggregationTypeName);
|
aggregationTypeName);
|
||||||
if (aggregatorSupplier instanceof RangeAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof RangeAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected RangeAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected RangeAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class BinaryRangeAggregatorFactory extends ValuesSourceAggregatorFactory
|
||||||
SearchContext searchContext, Aggregator parent,
|
SearchContext searchContext, Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
IpRangeAggregationBuilder.NAME);
|
IpRangeAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof IpRangeAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof IpRangeAggregatorSupplier == false) {
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class GeoDistanceRangeAggregatorFactory extends ValuesSourceAggregatorFac
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
||||||
.getAggregator(config.valueSourceType(), GeoDistanceAggregationBuilder.NAME);
|
.getAggregator(config, GeoDistanceAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof GeoDistanceAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof GeoDistanceAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected "
|
throw new AggregationExecutionException("Registry miss-match - expected "
|
||||||
+ GeoDistanceAggregatorSupplier.class.getName() + ", found [" + aggregatorSupplier.getClass().toString() + "]");
|
+ GeoDistanceAggregatorSupplier.class.getName() + ", found [" + aggregatorSupplier.getClass().toString() + "]");
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class DiversifiedAggregatorFactory extends ValuesSourceAggregatorFactory
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
|
|
||||||
AggregatorSupplier supplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier supplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
DiversifiedAggregationBuilder.NAME);
|
DiversifiedAggregationBuilder.NAME);
|
||||||
if (supplier instanceof DiversifiedAggregatorSupplier == false) {
|
if (supplier instanceof DiversifiedAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected " + DiversifiedAggregatorSupplier.class.toString() +
|
throw new AggregationExecutionException("Registry miss-match - expected " + DiversifiedAggregatorSupplier.class.toString() +
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class RareTermsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
return asMultiBucketAggregator(this, searchContext, parent);
|
return asMultiBucketAggregator(this, searchContext, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
RareTermsAggregationBuilder.NAME);
|
RareTermsAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof RareTermsAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof RareTermsAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected RareTermsAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected RareTermsAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -300,7 +300,7 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
SignificantTermsAggregationBuilder.NAME);
|
SignificantTermsAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof SignificantTermsAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof SignificantTermsAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected SignificantTermsAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected SignificantTermsAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -240,7 +240,7 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
TermsAggregationBuilder.NAME);
|
TermsAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof TermsAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof TermsAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected TermsAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected TermsAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -63,7 +63,7 @@ class AvgAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
AvgAggregationBuilder.NAME);
|
AvgAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CardinalityAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
CardinalityAggregationBuilder.NAME);
|
CardinalityAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof CardinalityAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof CardinalityAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected CardinalityAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected CardinalityAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
import org.elasticsearch.search.aggregations.Aggregator;
|
import org.elasticsearch.search.aggregations.Aggregator;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||||
|
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
||||||
|
@ -70,9 +71,12 @@ class ExtendedStatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
if (valuesSource instanceof Numeric == false) {
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
throw new AggregationExecutionException("ValuesSource type " + valuesSource.toString() + "is not supported for aggregation " +
|
ExtendedStatsAggregationBuilder.NAME);
|
||||||
this.name());
|
|
||||||
|
if (aggregatorSupplier instanceof ExtendedStatsAggregatorProvider == false) {
|
||||||
|
throw new AggregationExecutionException("Registry miss-match - expected ExtendedStatsAggregatorProvider, found [" +
|
||||||
|
aggregatorSupplier.getClass().toString() + "]");
|
||||||
}
|
}
|
||||||
return new ExtendedStatsAggregator(name, (Numeric) valuesSource, config.format(), searchContext,
|
return new ExtendedStatsAggregator(name, (Numeric) valuesSource, config.format(), searchContext,
|
||||||
parent, sigma, metadata);
|
parent, sigma, metadata);
|
||||||
|
|
|
@ -64,7 +64,7 @@ class GeoBoundsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry()
|
||||||
.getAggregator(config.valueSourceType(), GeoBoundsAggregationBuilder.NAME);
|
.getAggregator(config, GeoBoundsAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof GeoBoundsAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof GeoBoundsAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected "
|
throw new AggregationExecutionException("Registry miss-match - expected "
|
||||||
|
|
|
@ -60,7 +60,7 @@ class GeoCentroidAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
|
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
GeoCentroidAggregationBuilder.NAME);
|
GeoCentroidAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof GeoCentroidAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof GeoCentroidAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected "
|
throw new AggregationExecutionException("Registry miss-match - expected "
|
||||||
|
|
|
@ -62,7 +62,7 @@ class MaxAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
MaxAggregationBuilder.NAME);
|
MaxAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class MedianAbsoluteDeviationAggregatorFactory extends ValuesSourceAggreg
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
MedianAbsoluteDeviationAggregationBuilder.NAME);
|
MedianAbsoluteDeviationAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MedianAbsoluteDeviationAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MedianAbsoluteDeviationAggregatorSupplier == false) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ class MinAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
MinAggregationBuilder.NAME);
|
MinAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class PercentileRanksAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
PercentileRanksAggregationBuilder.NAME);
|
PercentileRanksAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof PercentilesAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof PercentilesAggregatorSupplier == false) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class PercentilesAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
|
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
PercentilesAggregationBuilder.NAME);
|
PercentilesAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof PercentilesAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof PercentilesAggregatorSupplier == false) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ class StatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
StatsAggregationBuilder.NAME);
|
StatsAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
SumAggregationBuilder.NAME);
|
SumAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof MetricAggregatorSupplier == false) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ValueCountAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
ValueCountAggregationBuilder.NAME);
|
ValueCountAggregationBuilder.NAME);
|
||||||
if (aggregatorSupplier instanceof ValueCountAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof ValueCountAggregatorSupplier == false) {
|
||||||
throw new AggregationExecutionException("Registry miss-match - expected ValueCountAggregatorSupplier, found [" +
|
throw new AggregationExecutionException("Registry miss-match - expected ValueCountAggregatorSupplier, found [" +
|
||||||
|
|
|
@ -346,6 +346,11 @@ public abstract class ValuesSourceAggregationBuilder<AB extends ValuesSourceAggr
|
||||||
protected final ValuesSourceAggregatorFactory doBuild(QueryShardContext queryShardContext, AggregatorFactory parent,
|
protected final ValuesSourceAggregatorFactory doBuild(QueryShardContext queryShardContext, AggregatorFactory parent,
|
||||||
Builder subFactoriesBuilder) throws IOException {
|
Builder subFactoriesBuilder) throws IOException {
|
||||||
ValuesSourceConfig config = resolveConfig(queryShardContext);
|
ValuesSourceConfig config = resolveConfig(queryShardContext);
|
||||||
|
if (queryShardContext.getValuesSourceRegistry().isRegistered(getType())) {
|
||||||
|
// Only test if the values source type is valid if the aggregation uses the registry
|
||||||
|
AggregatorSupplier supplier = queryShardContext.getValuesSourceRegistry().getAggregator(config, getType());
|
||||||
|
}
|
||||||
|
// TODO: We should pass the supplier in from here. Right now this just checks that the VST is valid
|
||||||
ValuesSourceAggregatorFactory factory = innerBuild(queryShardContext, config, parent, subFactoriesBuilder);
|
ValuesSourceAggregatorFactory factory = innerBuild(queryShardContext, config, parent, subFactoriesBuilder);
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ public class ValuesSourceConfig {
|
||||||
String aggregationName) {
|
String aggregationName) {
|
||||||
|
|
||||||
return internalResolve(context, userValueTypeHint, field, script, missing, timeZone, format, defaultValueSourceType,
|
return internalResolve(context, userValueTypeHint, field, script, missing, timeZone, format, defaultValueSourceType,
|
||||||
aggregationName, ValuesSourceConfig::getMappingFromRegistry);
|
ValuesSourceConfig::getMappingFromRegistry
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,7 +94,15 @@ public class ValuesSourceConfig {
|
||||||
ZoneId timeZone,
|
ZoneId timeZone,
|
||||||
String format,
|
String format,
|
||||||
ValuesSourceType defaultValueSourceType) {
|
ValuesSourceType defaultValueSourceType) {
|
||||||
return internalResolve(context, userValueTypeHint, field, script, missing, timeZone, format, defaultValueSourceType, null,
|
return internalResolve(
|
||||||
|
context,
|
||||||
|
userValueTypeHint,
|
||||||
|
field,
|
||||||
|
script,
|
||||||
|
missing,
|
||||||
|
timeZone,
|
||||||
|
format,
|
||||||
|
defaultValueSourceType,
|
||||||
ValuesSourceConfig::getLegacyMapping);
|
ValuesSourceConfig::getLegacyMapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,13 +114,13 @@ public class ValuesSourceConfig {
|
||||||
ZoneId timeZone,
|
ZoneId timeZone,
|
||||||
String format,
|
String format,
|
||||||
ValuesSourceType defaultValueSourceType,
|
ValuesSourceType defaultValueSourceType,
|
||||||
String aggregationName,
|
|
||||||
FieldResolver fieldResolver
|
FieldResolver fieldResolver
|
||||||
) {
|
) {
|
||||||
ValuesSourceConfig config;
|
ValuesSourceConfig config;
|
||||||
MappedFieldType fieldType = null;
|
MappedFieldType fieldType = null;
|
||||||
ValuesSourceType valuesSourceType = null;
|
ValuesSourceType valuesSourceType = null;
|
||||||
ValueType scriptValueType = userValueTypeHint;
|
ValueType scriptValueType = userValueTypeHint;
|
||||||
|
FieldContext fieldContext = null;
|
||||||
AggregationScript.LeafFactory aggregationScript = createScript(script, context); // returns null if script is null
|
AggregationScript.LeafFactory aggregationScript = createScript(script, context); // returns null if script is null
|
||||||
boolean unmapped = false;
|
boolean unmapped = false;
|
||||||
if (userValueTypeHint != null) {
|
if (userValueTypeHint != null) {
|
||||||
|
@ -134,16 +143,18 @@ public class ValuesSourceConfig {
|
||||||
*/
|
*/
|
||||||
unmapped = true;
|
unmapped = true;
|
||||||
aggregationScript = null; // Value scripts are not allowed on unmapped fields. What would that do, anyway?
|
aggregationScript = null; // Value scripts are not allowed on unmapped fields. What would that do, anyway?
|
||||||
} else if (valuesSourceType == null) {
|
} else {
|
||||||
|
fieldContext = new FieldContext(fieldType.name(), context.getForField(fieldType), fieldType);
|
||||||
|
if (valuesSourceType == null) {
|
||||||
// We have a field, and the user didn't specify a type, so get the type from the field
|
// We have a field, and the user didn't specify a type, so get the type from the field
|
||||||
valuesSourceType = fieldResolver.getValuesSourceType(context, fieldType, aggregationName, userValueTypeHint,
|
valuesSourceType = fieldResolver.getValuesSourceType(fieldContext, userValueTypeHint, defaultValueSourceType);
|
||||||
defaultValueSourceType);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (valuesSourceType == null) {
|
if (valuesSourceType == null) {
|
||||||
valuesSourceType = defaultValueSourceType;
|
valuesSourceType = defaultValueSourceType;
|
||||||
}
|
}
|
||||||
config = new ValuesSourceConfig(valuesSourceType, fieldType, unmapped, aggregationScript, scriptValueType , context);
|
config = new ValuesSourceConfig(valuesSourceType, fieldContext, unmapped, aggregationScript, scriptValueType, context::nowInMillis);
|
||||||
config.format(resolveFormat(format, valuesSourceType, timeZone, fieldType));
|
config.format(resolveFormat(format, valuesSourceType, timeZone, fieldType));
|
||||||
config.missing(missing);
|
config.missing(missing);
|
||||||
config.timezone(timeZone);
|
config.timezone(timeZone);
|
||||||
|
@ -153,37 +164,31 @@ public class ValuesSourceConfig {
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
private interface FieldResolver {
|
private interface FieldResolver {
|
||||||
ValuesSourceType getValuesSourceType(
|
ValuesSourceType getValuesSourceType(
|
||||||
QueryShardContext context,
|
FieldContext fieldContext,
|
||||||
MappedFieldType fieldType,
|
|
||||||
String aggregationName,
|
|
||||||
ValueType userValueTypeHint,
|
ValueType userValueTypeHint,
|
||||||
ValuesSourceType defaultValuesSourceType);
|
ValuesSourceType defaultValuesSourceType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ValuesSourceType getMappingFromRegistry(
|
private static ValuesSourceType getMappingFromRegistry(
|
||||||
QueryShardContext context,
|
FieldContext fieldContext,
|
||||||
MappedFieldType fieldType,
|
|
||||||
String aggregationName,
|
|
||||||
ValueType userValueTypeHint,
|
ValueType userValueTypeHint,
|
||||||
ValuesSourceType defaultValuesSourceType) {
|
ValuesSourceType defaultValuesSourceType
|
||||||
IndexFieldData<?> indexFieldData = context.getForField(fieldType);
|
) {
|
||||||
return context.getValuesSourceRegistry().getValuesSourceType(fieldType, aggregationName, indexFieldData,
|
return fieldContext.indexFieldData().getValuesSourceType();
|
||||||
userValueTypeHint, defaultValuesSourceType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ValuesSourceType getLegacyMapping(
|
private static ValuesSourceType getLegacyMapping(
|
||||||
QueryShardContext context,
|
FieldContext fieldContext,
|
||||||
MappedFieldType fieldType,
|
|
||||||
String aggregationName,
|
|
||||||
ValueType userValueTypeHint,
|
ValueType userValueTypeHint,
|
||||||
ValuesSourceType defaultValuesSourceType) {
|
ValuesSourceType defaultValuesSourceType
|
||||||
IndexFieldData<?> indexFieldData = context.getForField(fieldType);
|
) {
|
||||||
|
IndexFieldData<?> indexFieldData = fieldContext.indexFieldData();
|
||||||
if (indexFieldData instanceof IndexNumericFieldData) {
|
if (indexFieldData instanceof IndexNumericFieldData) {
|
||||||
return CoreValuesSourceType.NUMERIC;
|
return CoreValuesSourceType.NUMERIC;
|
||||||
} else if (indexFieldData instanceof IndexGeoPointFieldData) {
|
} else if (indexFieldData instanceof IndexGeoPointFieldData) {
|
||||||
return CoreValuesSourceType.GEOPOINT;
|
return CoreValuesSourceType.GEOPOINT;
|
||||||
} else if (fieldType instanceof RangeFieldMapper.RangeFieldType) {
|
} else if (fieldContext.fieldType() instanceof RangeFieldMapper.RangeFieldType) {
|
||||||
return CoreValuesSourceType.RANGE;
|
return CoreValuesSourceType.RANGE;
|
||||||
} else {
|
} else {
|
||||||
if (userValueTypeHint == null) {
|
if (userValueTypeHint == null) {
|
||||||
|
@ -192,7 +197,6 @@ public class ValuesSourceConfig {
|
||||||
return userValueTypeHint.getValuesSourceType();
|
return userValueTypeHint.getValuesSourceType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AggregationScript.LeafFactory createScript(Script script, QueryShardContext context) {
|
private static AggregationScript.LeafFactory createScript(Script script, QueryShardContext context) {
|
||||||
|
@ -220,14 +224,22 @@ public class ValuesSourceConfig {
|
||||||
*/
|
*/
|
||||||
public static ValuesSourceConfig resolveFieldOnly(MappedFieldType fieldType,
|
public static ValuesSourceConfig resolveFieldOnly(MappedFieldType fieldType,
|
||||||
QueryShardContext queryShardContext) {
|
QueryShardContext queryShardContext) {
|
||||||
return new ValuesSourceConfig(fieldType.getValuesSourceType(), fieldType, false, null, null, queryShardContext);
|
FieldContext fieldContext = new FieldContext(fieldType.name(), queryShardContext.getForField(fieldType), fieldType);
|
||||||
|
return new ValuesSourceConfig(
|
||||||
|
fieldContext.indexFieldData().getValuesSourceType(),
|
||||||
|
fieldContext,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
queryShardContext::nowInMillis
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for creating unmapped configs
|
* Convenience method for creating unmapped configs
|
||||||
*/
|
*/
|
||||||
public static ValuesSourceConfig resolveUnmapped(ValuesSourceType valuesSourceType, QueryShardContext queryShardContext) {
|
public static ValuesSourceConfig resolveUnmapped(ValuesSourceType valuesSourceType, QueryShardContext queryShardContext) {
|
||||||
return new ValuesSourceConfig(valuesSourceType, null, true, null, null, queryShardContext);
|
return new ValuesSourceConfig(valuesSourceType, null, true, null, null, queryShardContext::nowInMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ValuesSourceType valuesSourceType;
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
@ -241,23 +253,23 @@ public class ValuesSourceConfig {
|
||||||
private LongSupplier nowSupplier;
|
private LongSupplier nowSupplier;
|
||||||
|
|
||||||
|
|
||||||
public ValuesSourceConfig(ValuesSourceType valuesSourceType,
|
public ValuesSourceConfig(
|
||||||
MappedFieldType fieldType,
|
ValuesSourceType valuesSourceType,
|
||||||
|
FieldContext fieldContext,
|
||||||
boolean unmapped,
|
boolean unmapped,
|
||||||
AggregationScript.LeafFactory script,
|
AggregationScript.LeafFactory script,
|
||||||
ValueType scriptValueType,
|
ValueType scriptValueType,
|
||||||
QueryShardContext queryShardContext) {
|
LongSupplier nowSupplier
|
||||||
if (unmapped && fieldType != null) {
|
) {
|
||||||
|
if (unmapped && fieldContext != null) {
|
||||||
throw new IllegalStateException("value source config is invalid; marked as unmapped but specified a mapped field");
|
throw new IllegalStateException("value source config is invalid; marked as unmapped but specified a mapped field");
|
||||||
}
|
}
|
||||||
this.valuesSourceType = valuesSourceType;
|
this.valuesSourceType = valuesSourceType;
|
||||||
if (fieldType != null) {
|
this.fieldContext = fieldContext;
|
||||||
this.fieldContext = new FieldContext(fieldType.name(), queryShardContext.getForField(fieldType), fieldType);
|
|
||||||
}
|
|
||||||
this.unmapped = unmapped;
|
this.unmapped = unmapped;
|
||||||
this.script = script;
|
this.script = script;
|
||||||
this.scriptValueType = scriptValueType;
|
this.scriptValueType = scriptValueType;
|
||||||
this.nowSupplier = queryShardContext::nowInMillis;
|
this.nowSupplier = nowSupplier;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.search.aggregations.support;
|
package org.elasticsearch.search.aggregations.support;
|
||||||
|
|
||||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
|
|
||||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||||
import org.elasticsearch.index.mapper.RangeFieldMapper;
|
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.SearchModule;
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||||
|
@ -116,51 +112,27 @@ public class ValuesSourceRegistry {
|
||||||
return supportedTypes.get(valuesSourceType);
|
return supportedTypes.get(valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AggregatorSupplier getAggregator(ValuesSourceType valuesSourceType, String aggregationName) {
|
public boolean isRegistered(String aggregationName) {
|
||||||
if (aggregationName != null && aggregatorRegistry.containsKey(aggregationName)) {
|
return aggregatorRegistry.containsKey(aggregationName);
|
||||||
AggregatorSupplier supplier = findMatchingSuppier(valuesSourceType, aggregatorRegistry.get(aggregationName));
|
|
||||||
if (supplier == null) {
|
|
||||||
throw new AggregationExecutionException("ValuesSource type " + valuesSourceType.toString() +
|
|
||||||
" is not supported for aggregation" + aggregationName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AggregatorSupplier getAggregator(ValuesSourceConfig valuesSourceConfig, String aggregationName) {
|
||||||
|
if (aggregationName != null && aggregatorRegistry.containsKey(aggregationName)) {
|
||||||
|
AggregatorSupplier supplier = findMatchingSuppier(
|
||||||
|
valuesSourceConfig.valueSourceType(),
|
||||||
|
aggregatorRegistry.get(aggregationName)
|
||||||
|
);
|
||||||
|
if (supplier == null) {
|
||||||
|
// TODO: push building the description into ValuesSourceConfig
|
||||||
|
MappedFieldType fieldType = valuesSourceConfig.fieldContext().fieldType();
|
||||||
|
String fieldDescription = fieldType.typeName() + "(" + fieldType.toString() + ")";
|
||||||
|
throw new IllegalArgumentException("Field [" + fieldType.name() + "] of type [" + fieldDescription +
|
||||||
|
"] is not supported for aggregation [" + aggregationName + "]"); }
|
||||||
return supplier;
|
return supplier;
|
||||||
}
|
}
|
||||||
throw new AggregationExecutionException("Unregistered Aggregation [" + aggregationName + "]");
|
throw new AggregationExecutionException("Unregistered Aggregation [" + aggregationName + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValuesSourceType getValuesSourceType(MappedFieldType fieldType, String aggregationName,
|
|
||||||
// TODO: the following arguments are only needed for the legacy case
|
|
||||||
IndexFieldData<?> indexFieldData,
|
|
||||||
ValueType valueType,
|
|
||||||
ValuesSourceType defaultValuesSourceType) {
|
|
||||||
if (aggregationName != null && aggregatorRegistry.containsKey(aggregationName)) {
|
|
||||||
// This will throw if the field doesn't support values sources, although really we probably threw much earlier in that case
|
|
||||||
ValuesSourceType valuesSourceType = fieldType.getValuesSourceType();
|
|
||||||
if (aggregatorRegistry.get(aggregationName) != null
|
|
||||||
&& findMatchingSuppier(valuesSourceType, aggregatorRegistry.get(aggregationName)) != null) {
|
|
||||||
return valuesSourceType;
|
|
||||||
}
|
|
||||||
String fieldDescription = fieldType.typeName() + "(" + fieldType.toString() + ")";
|
|
||||||
throw new IllegalArgumentException("Field [" + fieldType.name() + "] of type [" + fieldDescription +
|
|
||||||
"] is not supported for aggregation [" + aggregationName + "]");
|
|
||||||
} else {
|
|
||||||
// TODO: Legacy resolve logic; remove this after converting all aggregations to the new system
|
|
||||||
if (indexFieldData instanceof IndexNumericFieldData) {
|
|
||||||
return CoreValuesSourceType.NUMERIC;
|
|
||||||
} else if (indexFieldData instanceof IndexGeoPointFieldData) {
|
|
||||||
return CoreValuesSourceType.GEOPOINT;
|
|
||||||
} else if (fieldType instanceof RangeFieldMapper.RangeFieldType) {
|
|
||||||
return CoreValuesSourceType.RANGE;
|
|
||||||
} else {
|
|
||||||
if (valueType == null) {
|
|
||||||
return defaultValuesSourceType;
|
|
||||||
} else {
|
|
||||||
return valueType.getValuesSourceType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public AggregationUsageService getUsageService() {
|
public AggregationUsageService getUsageService() {
|
||||||
return usageService;
|
return usageService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.elasticsearch.search.aggregations.support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* This package holds shared code for the aggregations framework, especially around dealing with values.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <h2> Key Classes </h2>
|
||||||
|
*
|
||||||
|
* <h3> {@link org.elasticsearch.search.aggregations.support.ValuesSource} and its subclasses </h3>
|
||||||
|
* <p>
|
||||||
|
* These are thin wrappers which provide a unified interface to different ways of getting input data (e.g. DocValues from Lucene, or script
|
||||||
|
* output). A class hierarchy defines the type of values returned by the source. The top level sub-classes define type-specific behavior,
|
||||||
|
* such as {@link org.elasticsearch.search.aggregations.support.ValuesSource.Numeric#isFloatingPoint()}. Second level subclasses are
|
||||||
|
* then specialized based on where they read values from, e.g. script or field cases. There are also adapter classes like
|
||||||
|
* {@link org.elasticsearch.search.aggregations.bucket.geogrid.CellIdSource} which do run-time conversion from one type to another, often
|
||||||
|
* dependent on a user specified parameter (precision in that case).
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <h3> {@link org.elasticsearch.search.aggregations.support.ValuesSourceRegistry} </h3>
|
||||||
|
* <p>
|
||||||
|
* ValuesSourceRegistry stores the mappings for what types are supported by what aggregations. It is configured at startup, when
|
||||||
|
* {@link org.elasticsearch.search.SearchModule} is configuring aggregations. It shouldn't be necessary to access the registry in most
|
||||||
|
* cases, but you can get a read copy from {@link org.elasticsearch.index.query.QueryShardContext#getValuesSourceRegistry()} if necessary.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <h3> {@link org.elasticsearch.search.aggregations.support.ValuesSourceType} </h3>
|
||||||
|
* <p>
|
||||||
|
* ValuesSourceTypes are the quantum of support in the aggregations framework, and provide a common language between fields and
|
||||||
|
* aggregations. Fields which support aggregation set a ValuesSourceType on their {@link org.elasticsearch.index.fielddata.IndexFieldData}
|
||||||
|
* implementations, and aggregations register what types they support via one of the
|
||||||
|
* {@link org.elasticsearch.search.aggregations.support.ValuesSourceRegistry.Builder#register} methods. The VaulesSourceType itself holds
|
||||||
|
* information on how to with values of that type, including methods for creating
|
||||||
|
* {@link org.elasticsearch.search.aggregations.support.ValuesSource} instances and {@link org.elasticsearch.search.DocValueFormat}
|
||||||
|
* instances.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <h3> {@link org.elasticsearch.search.aggregations.support.ValuesSourceConfig} </h3>
|
||||||
|
* <p>
|
||||||
|
* There are two things going on in ValuesSourceConfig. First, there is a collection of static factory methods to build valid configs for
|
||||||
|
* different situations. {@link org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder#resolveConfig} has a good
|
||||||
|
* default for what to call here and generally aggregations shouldn't need to deviate from that.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Once properly constructed, the ValuesSourceConfig provides access to the ValuesSource instance, as well as related information like the
|
||||||
|
* formatter. Aggregations are free to use this information as needed, such as Max and Min which inspect the field context to see if they
|
||||||
|
* can apply an optimization.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <h2> Classes we are trying to phase out </h2>
|
||||||
|
* <h3> {@link org.elasticsearch.search.aggregations.support.ValueType} </h3>
|
||||||
|
* <p>
|
||||||
|
* This class is primarily used for parsing user type hints, and is deprecated for new use. Work is ongoing to remove it from existing
|
||||||
|
* code.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
*/
|
|
@ -41,6 +41,7 @@ import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
|
||||||
import org.elasticsearch.index.mapper.TextFieldMapper;
|
import org.elasticsearch.index.mapper.TextFieldMapper;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||||
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.FieldMaskingReader;
|
import org.elasticsearch.test.FieldMaskingReader;
|
||||||
|
|
||||||
|
@ -88,15 +89,21 @@ public class FieldDataCacheTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedSetOrdinalsIndexFieldData createSortedDV(String fieldName, IndexFieldDataCache indexFieldDataCache) {
|
private SortedSetOrdinalsIndexFieldData createSortedDV(String fieldName, IndexFieldDataCache indexFieldDataCache) {
|
||||||
return new SortedSetOrdinalsIndexFieldData(createIndexSettings(), indexFieldDataCache, fieldName, new NoneCircuitBreakerService(),
|
return new SortedSetOrdinalsIndexFieldData(createIndexSettings(), indexFieldDataCache, fieldName, CoreValuesSourceType.BYTES,
|
||||||
AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
new NoneCircuitBreakerService(), AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagedBytesIndexFieldData createPagedBytes(String fieldName, IndexFieldDataCache indexFieldDataCache) {
|
private PagedBytesIndexFieldData createPagedBytes(String fieldName, IndexFieldDataCache indexFieldDataCache) {
|
||||||
return new PagedBytesIndexFieldData(createIndexSettings(), fieldName, indexFieldDataCache, new NoneCircuitBreakerService(),
|
return new PagedBytesIndexFieldData(
|
||||||
|
createIndexSettings(),
|
||||||
|
fieldName,
|
||||||
|
CoreValuesSourceType.BYTES,
|
||||||
|
indexFieldDataCache,
|
||||||
|
new NoneCircuitBreakerService(),
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
|
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexSettings createIndexSettings() {
|
private IndexSettings createIndexSettings() {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.N
|
||||||
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -48,6 +49,11 @@ public class NoOrdinalsStringFieldDataTests extends PagedBytesStringFieldDataTes
|
||||||
return in.getFieldName();
|
return in.getFieldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return in.getValuesSourceType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafFieldData load(LeafReaderContext context) {
|
public LeafFieldData load(LeafReaderContext context) {
|
||||||
return in.load(context);
|
return in.load(context);
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
|
||||||
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
|
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
|
@ -93,6 +94,11 @@ public class FunctionScoreTests extends ESTestCase {
|
||||||
return "test";
|
return "test";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
throw new UnsupportedOperationException(UNSUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafFieldData load(LeafReaderContext context) {
|
public LeafFieldData load(LeafReaderContext context) {
|
||||||
return new LeafFieldData() {
|
return new LeafFieldData() {
|
||||||
|
@ -181,6 +187,11 @@ public class FunctionScoreTests extends ESTestCase {
|
||||||
return "test";
|
return "test";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
throw new UnsupportedOperationException(UNSUPPORTED);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafNumericFieldData load(LeafReaderContext context) {
|
public LeafNumericFieldData load(LeafReaderContext context) {
|
||||||
return new LeafNumericFieldData() {
|
return new LeafNumericFieldData() {
|
||||||
|
|
|
@ -165,7 +165,6 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||||
TYPE_TEST_BLACKLIST = blacklist;
|
TYPE_TEST_BLACKLIST = blacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows subclasses to provide alternate names for the provided field type, which
|
* Allows subclasses to provide alternate names for the provided field type, which
|
||||||
* can be useful when testing aggregations on field aliases.
|
* can be useful when testing aggregations on field aliases.
|
||||||
|
@ -720,7 +719,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||||
IndexSearcher indexSearcher = newIndexSearcher(indexReader);
|
IndexSearcher indexSearcher = newIndexSearcher(indexReader);
|
||||||
AggregationBuilder aggregationBuilder = createAggBuilderForTypeTest(fieldType, fieldName);
|
AggregationBuilder aggregationBuilder = createAggBuilderForTypeTest(fieldType, fieldName);
|
||||||
|
|
||||||
ValuesSourceType vst = fieldType.getValuesSourceType();
|
ValuesSourceType vst = fieldToVST(fieldType);
|
||||||
// TODO in the future we can make this more explicit with expectThrows(), when the exceptions are standardized
|
// TODO in the future we can make this more explicit with expectThrows(), when the exceptions are standardized
|
||||||
AssertionError failure = null;
|
AssertionError failure = null;
|
||||||
try {
|
try {
|
||||||
|
@ -744,6 +743,11 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ValuesSourceType fieldToVST(MappedFieldType fieldType) {
|
||||||
|
return fieldType.fielddataBuilder("")
|
||||||
|
.build(createIndexSettings(), fieldType, null, null, null).getValuesSourceType();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to write a single document with a single value specific to the requested fieldType.
|
* Helper method to write a single document with a single value specific to the requested fieldType.
|
||||||
*
|
*
|
||||||
|
@ -753,7 +757,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||||
private void writeTestDoc(MappedFieldType fieldType, String fieldName, RandomIndexWriter iw) throws IOException {
|
private void writeTestDoc(MappedFieldType fieldType, String fieldName, RandomIndexWriter iw) throws IOException {
|
||||||
|
|
||||||
String typeName = fieldType.typeName();
|
String typeName = fieldType.typeName();
|
||||||
ValuesSourceType vst = fieldType.getValuesSourceType();
|
ValuesSourceType vst = fieldToVST(fieldType);
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
String json;
|
String json;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class BoxplotAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
BoxplotAggregationBuilder.NAME);
|
BoxplotAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof BoxplotAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof BoxplotAggregatorSupplier == false) {
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.elasticsearch.index.query.QueryShardException;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||||
|
@ -198,7 +197,7 @@ public class HistogramFieldMapper extends FieldMapper {
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
|
|
||||||
return new IndexHistogramFieldData(indexSettings.getIndex(), fieldType.name()) {
|
return new IndexHistogramFieldData(indexSettings.getIndex(), fieldType.name(), AnalyticsValuesSourceType.HISTOGRAM) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LeafHistogramFieldData load(LeafReaderContext context) {
|
public LeafHistogramFieldData load(LeafReaderContext context) {
|
||||||
|
@ -275,11 +274,6 @@ public class HistogramFieldMapper extends FieldMapper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return AnalyticsValuesSourceType.HISTOGRAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query existsQuery(QueryShardContext context) {
|
public Query existsQuery(QueryShardContext context) {
|
||||||
if (hasDocValues()) {
|
if (hasDocValues()) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ class StringStatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||||
Aggregator parent,
|
Aggregator parent,
|
||||||
boolean collectsFromSingleBucket,
|
boolean collectsFromSingleBucket,
|
||||||
Map<String, Object> metadata) throws IOException {
|
Map<String, Object> metadata) throws IOException {
|
||||||
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config.valueSourceType(),
|
AggregatorSupplier aggregatorSupplier = queryShardContext.getValuesSourceRegistry().getAggregator(config,
|
||||||
StringStatsAggregationBuilder.NAME);
|
StringStatsAggregationBuilder.NAME);
|
||||||
|
|
||||||
if (aggregatorSupplier instanceof StringStatsAggregatorSupplier == false) {
|
if (aggregatorSupplier instanceof StringStatsAggregatorSupplier == false) {
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.TypeParsers;
|
import org.elasticsearch.index.mapper.TypeParsers;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
@ -158,7 +157,7 @@ public class ConstantKeywordFieldMapper extends FieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
return new ConstantIndexFieldData.Builder(mapperService -> value);
|
return new ConstantIndexFieldData.Builder(mapperService -> value, CoreValuesSourceType.BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -240,10 +239,6 @@ public class ConstantKeywordFieldMapper extends FieldMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantKeywordFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
ConstantKeywordFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
||||||
|
|
|
@ -347,13 +347,9 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new KeyedFlatObjectFieldData.Builder(key);
|
return new KeyedFlatObjectFieldData.Builder(key, CoreValuesSourceType.BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -386,6 +382,11 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
||||||
return delegate.getFieldName();
|
return delegate.getFieldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return delegate.getValuesSourceType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortField sortField(Object missingValue,
|
public SortField sortField(Object missingValue,
|
||||||
MultiValueMode sortMode,
|
MultiValueMode sortMode,
|
||||||
|
@ -448,9 +449,11 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
private final String key;
|
private final String key;
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
Builder(String key) {
|
Builder(String key, ValuesSourceType valuesSourceType) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -461,7 +464,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
||||||
MapperService mapperService) {
|
MapperService mapperService) {
|
||||||
String fieldName = fieldType.name();
|
String fieldName = fieldType.name();
|
||||||
IndexOrdinalsFieldData delegate = new SortedSetOrdinalsIndexFieldData(indexSettings,
|
IndexOrdinalsFieldData delegate = new SortedSetOrdinalsIndexFieldData(indexSettings,
|
||||||
cache, fieldName, breakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
cache, fieldName, valuesSourceType, breakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
||||||
return new KeyedFlatObjectFieldData(key, delegate);
|
return new KeyedFlatObjectFieldData(key, delegate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,13 +540,9 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new SortedSetOrdinalsIndexFieldData.Builder();
|
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlatObjectFieldParser fieldParser;
|
private FlatObjectFieldParser fieldParser;
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.index.mapper.TextFieldMapper;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||||
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.xpack.core.security.authz.accesscontrol.FieldSubsetReader;
|
import org.elasticsearch.xpack.core.security.authz.accesscontrol.FieldSubsetReader;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -61,8 +62,8 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
|
||||||
String name = "_field";
|
String name = "_field";
|
||||||
indexFieldDataCache = new DummyAccountingFieldDataCache();
|
indexFieldDataCache = new DummyAccountingFieldDataCache();
|
||||||
sortedSetOrdinalsIndexFieldData = new SortedSetOrdinalsIndexFieldData(indexSettings,indexFieldDataCache, name,
|
sortedSetOrdinalsIndexFieldData = new SortedSetOrdinalsIndexFieldData(indexSettings,indexFieldDataCache, name,
|
||||||
circuitBreakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
CoreValuesSourceType.BYTES, circuitBreakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
||||||
pagedBytesIndexFieldData = new PagedBytesIndexFieldData(indexSettings, name, indexFieldDataCache,
|
pagedBytesIndexFieldData = new PagedBytesIndexFieldData(indexSettings, name, CoreValuesSourceType.BYTES, indexFieldDataCache,
|
||||||
circuitBreakerService, TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
circuitBreakerService, TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
||||||
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
|
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE);
|
||||||
|
|
|
@ -22,16 +22,19 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShapeFieldData {
|
public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShapeFieldData {
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
AbstractLatLonShapeIndexFieldData(Index index, String fieldName) {
|
AbstractLatLonShapeIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,6 +42,11 @@ public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShape
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
@ -56,8 +64,8 @@ public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShape
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LatLonShapeIndexFieldData extends AbstractLatLonShapeIndexFieldData {
|
public static class LatLonShapeIndexFieldData extends AbstractLatLonShapeIndexFieldData {
|
||||||
public LatLonShapeIndexFieldData(Index index, String fieldName) {
|
public LatLonShapeIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
super(index, fieldName);
|
super(index, fieldName, valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,11 +103,16 @@ public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShape
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
|
public Builder(ValuesSourceType valuesSourceType) {
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
// ignore breaker
|
// ignore breaker
|
||||||
return new LatLonShapeIndexFieldData(indexSettings.getIndex(), fieldType.name());
|
return new LatLonShapeIndexFieldData(indexSettings.getIndex(), fieldType.name(), valuesSourceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.TypeParsers;
|
import org.elasticsearch.index.mapper.TypeParsers;
|
||||||
import org.elasticsearch.index.query.VectorGeoShapeQueryProcessor;
|
import org.elasticsearch.index.query.VectorGeoShapeQueryProcessor;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
import org.elasticsearch.xpack.spatial.index.fielddata.AbstractLatLonShapeIndexFieldData;
|
import org.elasticsearch.xpack.spatial.index.fielddata.AbstractLatLonShapeIndexFieldData;
|
||||||
import org.elasticsearch.xpack.spatial.index.fielddata.CentroidCalculator;
|
import org.elasticsearch.xpack.spatial.index.fielddata.CentroidCalculator;
|
||||||
import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType;
|
import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType;
|
||||||
|
@ -146,12 +145,7 @@ public class GeoShapeWithDocValuesFieldMapper extends GeoShapeFieldMapper {
|
||||||
|
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
return new AbstractLatLonShapeIndexFieldData.Builder();
|
return new AbstractLatLonShapeIndexFieldData.Builder(GeoShapeValuesSourceType.instance());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return GeoShapeValuesSourceType.instance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.elasticsearch.search.aggregations.bucket.geogrid.GeoTileGridAggregati
|
||||||
import org.elasticsearch.search.aggregations.metrics.GeoCentroidAggregationBuilder;
|
import org.elasticsearch.search.aggregations.metrics.GeoCentroidAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.metrics.GeoCentroidAggregatorSupplier;
|
import org.elasticsearch.search.aggregations.metrics.GeoCentroidAggregatorSupplier;
|
||||||
import org.elasticsearch.search.aggregations.metrics.GeoGridAggregatorSupplier;
|
import org.elasticsearch.search.aggregations.metrics.GeoGridAggregatorSupplier;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.VersionUtils;
|
import org.elasticsearch.test.VersionUtils;
|
||||||
|
@ -35,7 +36,8 @@ public class SpatialPluginTests extends ESTestCase {
|
||||||
registrar.forEach(c -> c.accept(registryBuilder));
|
registrar.forEach(c -> c.accept(registryBuilder));
|
||||||
ValuesSourceRegistry registry = registryBuilder.build();
|
ValuesSourceRegistry registry = registryBuilder.build();
|
||||||
GeoCentroidAggregatorSupplier centroidSupplier = (GeoCentroidAggregatorSupplier) registry.getAggregator(
|
GeoCentroidAggregatorSupplier centroidSupplier = (GeoCentroidAggregatorSupplier) registry.getAggregator(
|
||||||
GeoShapeValuesSourceType.instance(), GeoCentroidAggregationBuilder.NAME);
|
new ValuesSourceConfig(GeoShapeValuesSourceType.instance(), null, false, null, null, null),
|
||||||
|
GeoCentroidAggregationBuilder.NAME);
|
||||||
if (License.OperationMode.TRIAL != operationMode &&
|
if (License.OperationMode.TRIAL != operationMode &&
|
||||||
License.OperationMode.compare(operationMode, License.OperationMode.GOLD) < 0) {
|
License.OperationMode.compare(operationMode, License.OperationMode.GOLD) < 0) {
|
||||||
ElasticsearchSecurityException exception = expectThrows(ElasticsearchSecurityException.class,
|
ElasticsearchSecurityException exception = expectThrows(ElasticsearchSecurityException.class,
|
||||||
|
@ -55,7 +57,8 @@ public class SpatialPluginTests extends ESTestCase {
|
||||||
registrar.forEach(c -> c.accept(registryBuilder));
|
registrar.forEach(c -> c.accept(registryBuilder));
|
||||||
ValuesSourceRegistry registry = registryBuilder.build();
|
ValuesSourceRegistry registry = registryBuilder.build();
|
||||||
GeoGridAggregatorSupplier supplier = (GeoGridAggregatorSupplier) registry.getAggregator(
|
GeoGridAggregatorSupplier supplier = (GeoGridAggregatorSupplier) registry.getAggregator(
|
||||||
GeoShapeValuesSourceType.instance(), builderName);
|
new ValuesSourceConfig(GeoShapeValuesSourceType.instance(), null, false, null, null, null),
|
||||||
|
builderName);
|
||||||
if (License.OperationMode.TRIAL != operationMode &&
|
if (License.OperationMode.TRIAL != operationMode &&
|
||||||
License.OperationMode.compare(operationMode, License.OperationMode.GOLD) < 0) {
|
License.OperationMode.compare(operationMode, License.OperationMode.GOLD) < 0) {
|
||||||
ElasticsearchSecurityException exception = expectThrows(ElasticsearchSecurityException.class,
|
ElasticsearchSecurityException exception = expectThrows(ElasticsearchSecurityException.class,
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
|
||||||
import org.elasticsearch.xpack.vectors.query.VectorIndexFieldData;
|
import org.elasticsearch.xpack.vectors.query.VectorIndexFieldData;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -148,12 +147,7 @@ public class DenseVectorFieldMapper extends FieldMapper implements ArrayValueMap
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
return new VectorIndexFieldData.Builder(true);
|
return new VectorIndexFieldData.Builder(true, CoreValuesSourceType.BYTES);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.query.QueryShardContext;
|
import org.elasticsearch.index.query.QueryShardContext;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
|
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||||
import org.elasticsearch.xpack.vectors.query.VectorIndexFieldData;
|
import org.elasticsearch.xpack.vectors.query.VectorIndexFieldData;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -118,7 +119,7 @@ public class SparseVectorFieldMapper extends FieldMapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
return new VectorIndexFieldData.Builder(false);
|
return new VectorIndexFieldData.Builder(false, CoreValuesSourceType.BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.search.DocValueFormat;
|
import org.elasticsearch.search.DocValueFormat;
|
||||||
import org.elasticsearch.search.MultiValueMode;
|
import org.elasticsearch.search.MultiValueMode;
|
||||||
|
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||||
import org.elasticsearch.search.sort.BucketedSort;
|
import org.elasticsearch.search.sort.BucketedSort;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
|
||||||
|
@ -30,9 +31,11 @@ public class VectorIndexFieldData implements IndexFieldData<VectorDVLeafFieldDat
|
||||||
protected final Index index;
|
protected final Index index;
|
||||||
protected final String fieldName;
|
protected final String fieldName;
|
||||||
private final boolean isDense;
|
private final boolean isDense;
|
||||||
|
protected final ValuesSourceType valuesSourceType;
|
||||||
|
|
||||||
public VectorIndexFieldData(Index index, String fieldName, boolean isDense) {
|
public VectorIndexFieldData(Index index, String fieldName, boolean isDense, ValuesSourceType valuesSourceType) {
|
||||||
this.isDense = isDense;
|
this.isDense = isDense;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +45,11 @@ public class VectorIndexFieldData implements IndexFieldData<VectorDVLeafFieldDat
|
||||||
return fieldName;
|
return fieldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValuesSourceType getValuesSourceType() {
|
||||||
|
return valuesSourceType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void clear() {
|
public final void clear() {
|
||||||
// can't do
|
// can't do
|
||||||
|
@ -75,15 +83,17 @@ public class VectorIndexFieldData implements IndexFieldData<VectorDVLeafFieldDat
|
||||||
|
|
||||||
public static class Builder implements IndexFieldData.Builder {
|
public static class Builder implements IndexFieldData.Builder {
|
||||||
private final boolean isDense;
|
private final boolean isDense;
|
||||||
public Builder(boolean isDense) {
|
private final ValuesSourceType valuesSourceType;
|
||||||
|
public Builder(boolean isDense, ValuesSourceType valuesSourceType) {
|
||||||
this.isDense = isDense;
|
this.isDense = isDense;
|
||||||
|
this.valuesSourceType = valuesSourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
final String fieldName = fieldType.name();
|
final String fieldName = fieldType.name();
|
||||||
return new VectorIndexFieldData(indexSettings.getIndex(), fieldName, isDense);
|
return new VectorIndexFieldData(indexSettings.getIndex(), fieldName, isDense, valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -806,21 +806,16 @@ public class WildcardFieldMapper extends FieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||||
return new WildcardBytesBinaryIndexFieldData(indexSettings.getIndex(), fieldType.name());
|
return new WildcardBytesBinaryIndexFieldData(indexSettings.getIndex(), fieldType.name(), CoreValuesSourceType.BYTES);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ValuesSourceType getValuesSourceType() {
|
|
||||||
return CoreValuesSourceType.BYTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class WildcardBytesBinaryIndexFieldData extends BytesBinaryIndexFieldData {
|
static class WildcardBytesBinaryIndexFieldData extends BytesBinaryIndexFieldData {
|
||||||
|
|
||||||
WildcardBytesBinaryIndexFieldData(Index index, String fieldName) {
|
WildcardBytesBinaryIndexFieldData(Index index, String fieldName, ValuesSourceType valuesSourceType) {
|
||||||
super(index, fieldName);
|
super(index, fieldName, valuesSourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue