We never used the `IndexSettings` parameter and we only used the `MappedFieldType` parameter to get the name of the field which we already know everywhere where we build the `IFD.Builder`. This allows us to drop a fair bit of ceremony from a couple of tests.
This commit is contained in:
parent
466e947b0e
commit
6f6076e208
|
@ -38,7 +38,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.FieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
|
@ -267,12 +266,15 @@ public class ScaledFloatFieldMapper extends FieldMapper {
|
|||
failIfNoDocValues();
|
||||
return new IndexFieldData.Builder() {
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
public IndexFieldData<?> build(
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
final IndexNumericFieldData scaledValues = new SortedNumericIndexFieldData.Builder(
|
||||
name(),
|
||||
IndexNumericFieldData.NumericType.LONG
|
||||
)
|
||||
.build(indexSettings, fieldType, cache, breakerService, mapperService);
|
||||
).build(cache, breakerService, mapperService);
|
||||
return new ScaledFloatIndexFieldData(scaledValues, scalingFactor);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -29,11 +29,7 @@ import org.apache.lucene.index.IndexWriterConfig;
|
|||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.core.internal.io.IOUtils;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
|
||||
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
|
||||
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
|
||||
|
@ -151,18 +147,10 @@ public class ScaledFloatFieldTypeTests extends FieldTypeTestCase {
|
|||
doc.add(new SortedNumericDocValuesField("scaled_float2", 12));
|
||||
w.addDocument(doc);
|
||||
try (DirectoryReader reader = DirectoryReader.open(w)) {
|
||||
IndexMetadata indexMetadata = new IndexMetadata.Builder("index").settings(
|
||||
Settings.builder()
|
||||
.put("index.version.created", Version.CURRENT)
|
||||
.put("index.number_of_shards", 1)
|
||||
.put("index.number_of_replicas", 0).build()).build();
|
||||
IndexSettings indexSettings = new IndexSettings(indexMetadata, Settings.EMPTY);
|
||||
|
||||
// single-valued
|
||||
ScaledFloatFieldMapper.ScaledFloatFieldType f1
|
||||
= new ScaledFloatFieldMapper.ScaledFloatFieldType("scaled_float1", scalingFactor);
|
||||
IndexNumericFieldData fielddata = (IndexNumericFieldData) f1.fielddataBuilder("index")
|
||||
.build(indexSettings, f1, null, null, null);
|
||||
IndexNumericFieldData fielddata = (IndexNumericFieldData) f1.fielddataBuilder("index").build(null, null, null);
|
||||
assertEquals(fielddata.getNumericType(), IndexNumericFieldData.NumericType.DOUBLE);
|
||||
LeafNumericFieldData leafFieldData = fielddata.load(reader.leaves().get(0));
|
||||
SortedNumericDoubleValues values = leafFieldData.getDoubleValues();
|
||||
|
@ -173,7 +161,7 @@ public class ScaledFloatFieldTypeTests extends FieldTypeTestCase {
|
|||
// multi-valued
|
||||
ScaledFloatFieldMapper.ScaledFloatFieldType f2
|
||||
= new ScaledFloatFieldMapper.ScaledFloatFieldType("scaled_float2", scalingFactor);
|
||||
fielddata = (IndexNumericFieldData) f2.fielddataBuilder("index").build(indexSettings, f2, null, null, null);
|
||||
fielddata = (IndexNumericFieldData) f2.fielddataBuilder("index").build(null, null, null);
|
||||
leafFieldData = fielddata.load(reader.leaves().get(0));
|
||||
values = leafFieldData.getDoubleValues();
|
||||
assertTrue(values.advanceExact(0));
|
||||
|
|
|
@ -90,7 +90,7 @@ public class MetaJoinFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -108,7 +108,7 @@ public final class ParentIdFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -218,7 +218,7 @@ public final class ParentJoinFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -729,8 +729,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
|
|||
IndexFieldData.Builder builder = fieldType.fielddataBuilder(shardContext.getFullyQualifiedIndex().getName());
|
||||
IndexFieldDataCache cache = new IndexFieldDataCache.None();
|
||||
CircuitBreakerService circuitBreaker = new NoneCircuitBreakerService();
|
||||
return (IFD) builder.build(shardContext.getIndexSettings(), fieldType, cache, circuitBreaker,
|
||||
shardContext.getMapperService());
|
||||
return (IFD) builder.build(cache, circuitBreaker, shardContext.getMapperService());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,7 +104,7 @@ public class Murmur3FieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedNumericIndexFieldData.Builder(NumericType.LONG);
|
||||
return new SortedNumericIndexFieldData.Builder(name(), NumericType.LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,9 +36,7 @@ import org.apache.lucene.util.BitSet;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -253,8 +251,7 @@ public interface IndexFieldData<FD extends LeafFieldData> {
|
|||
|
||||
interface Builder {
|
||||
|
||||
IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService);
|
||||
IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService);
|
||||
}
|
||||
|
||||
interface Global<FD extends LeafFieldData> extends IndexFieldData<FD> {
|
||||
|
|
|
@ -131,7 +131,7 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo
|
|||
}
|
||||
}
|
||||
|
||||
return (IFD) builder.build(indexSettings, fieldType, cache, circuitBreakerService, mapperService);
|
||||
return (IFD) builder.build(cache, circuitBreakerService, mapperService);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,13 +26,11 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
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.IndexGeoPointFieldData;
|
||||
import org.elasticsearch.index.fielddata.LeafGeoPointFieldData;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -111,16 +109,18 @@ public abstract class AbstractLatLonPointIndexFieldData implements IndexGeoPoint
|
|||
}
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
private final String name;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(ValuesSourceType valuesSourceType) {
|
||||
public Builder(String name, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
public IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
// ignore breaker
|
||||
return new LatLonPointIndexFieldData(fieldType.name(), valuesSourceType);
|
||||
return new LatLonPointIndexFieldData(name, valuesSourceType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,10 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
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.fieldcomparator.BytesRefFieldComparatorSource;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -40,22 +38,17 @@ import org.elasticsearch.search.sort.SortOrder;
|
|||
public class BinaryIndexFieldData implements IndexFieldData<BinaryDVLeafFieldData> {
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
private final String name;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(ValuesSourceType valuesSourceType) {
|
||||
public Builder(String name, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryIndexFieldData build(
|
||||
IndexSettings indexSettings,
|
||||
MappedFieldType fieldType,
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
final String fieldName = fieldType.name();
|
||||
return new BinaryIndexFieldData(fieldName, valuesSourceType);
|
||||
public BinaryIndexFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new BinaryIndexFieldData(name, valuesSourceType);
|
||||
}
|
||||
}
|
||||
protected final String fieldName;
|
||||
|
|
|
@ -24,11 +24,9 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -90,19 +88,18 @@ public class BytesBinaryIndexFieldData implements IndexFieldData<BytesBinaryDVLe
|
|||
}
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
ValuesSourceType valuesSourceType;
|
||||
private final String name;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(ValuesSourceType valuesSourceType) {
|
||||
public Builder(String name, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
public IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
// Ignore breaker
|
||||
final String fieldName = fieldType.name();
|
||||
return new BytesBinaryIndexFieldData(fieldName, valuesSourceType);
|
||||
return new BytesBinaryIndexFieldData(name, valuesSourceType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,15 +29,13 @@ import org.apache.lucene.util.Accountable;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.AbstractSortedDocValues;
|
||||
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
|
||||
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.IndexOrdinalsFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
|
||||
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.TextFieldMapper;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
|
@ -57,17 +55,18 @@ public class ConstantIndexFieldData extends AbstractIndexOrdinalsFieldData {
|
|||
public static class Builder implements IndexFieldData.Builder {
|
||||
|
||||
private final Function<MapperService, String> valueFunction;
|
||||
private final String name;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(Function<MapperService, String> valueFunction, ValuesSourceType valuesSourceType) {
|
||||
public Builder(Function<MapperService, String> valueFunction, String name, ValuesSourceType valuesSourceType) {
|
||||
this.valueFunction = valueFunction;
|
||||
this.name = name;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new ConstantIndexFieldData(fieldType.name(), valueFunction.apply(mapperService), valuesSourceType);
|
||||
public IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new ConstantIndexFieldData(name, valueFunction.apply(mapperService), valuesSourceType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.apache.lucene.util.packed.PackedLongValues;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.breaker.CircuitBreaker;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
|
@ -46,7 +45,6 @@ import org.elasticsearch.index.fielddata.RamAccountingTermsEnum;
|
|||
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
||||
import org.elasticsearch.index.fielddata.ordinals.Ordinals;
|
||||
import org.elasticsearch.index.fielddata.ordinals.OrdinalsBuilder;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -61,12 +59,13 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData {
|
|||
private static final Logger logger = LogManager.getLogger(PagedBytesIndexFieldData.class);
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
|
||||
private final String name;
|
||||
private final double minFrequency, maxFrequency;
|
||||
private final int minSegmentSize;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(double minFrequency, double maxFrequency, int minSegmentSize, ValuesSourceType valuesSourceType) {
|
||||
public Builder(String name, double minFrequency, double maxFrequency, int minSegmentSize, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.minFrequency = minFrequency;
|
||||
this.maxFrequency = maxFrequency;
|
||||
this.minSegmentSize = minSegmentSize;
|
||||
|
@ -74,9 +73,8 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IndexOrdinalsFieldData build(IndexSettings indexSettings, MappedFieldType fieldType,
|
||||
IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new PagedBytesIndexFieldData(fieldType.name(), valuesSourceType, cache, breakerService,
|
||||
public IndexOrdinalsFieldData build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new PagedBytesIndexFieldData(name, valuesSourceType, cache, breakerService,
|
||||
minFrequency, maxFrequency, minSegmentSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.lucene.index.SortedNumericDocValues;
|
|||
import org.apache.lucene.util.Accountable;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.time.DateUtils;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.FieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
|
@ -39,7 +38,6 @@ import org.elasticsearch.index.fielddata.LeafNumericFieldData;
|
|||
import org.elasticsearch.index.fielddata.NumericDoubleValues;
|
||||
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
|
||||
import org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.MultiValueMode;
|
||||
|
@ -56,23 +54,21 @@ import java.util.Objects;
|
|||
*/
|
||||
public class SortedNumericIndexFieldData extends IndexNumericFieldData {
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
|
||||
private final String name;
|
||||
private final NumericType numericType;
|
||||
|
||||
public Builder(NumericType numericType) {
|
||||
public Builder(String name, NumericType numericType) {
|
||||
this.name = name;
|
||||
this.numericType = numericType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedNumericIndexFieldData build(
|
||||
IndexSettings indexSettings,
|
||||
MappedFieldType fieldType,
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
final String fieldName = fieldType.name();
|
||||
return new SortedNumericIndexFieldData(fieldName, numericType);
|
||||
return new SortedNumericIndexFieldData(name, numericType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.lucene.search.SortedSetSortField;
|
|||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
|
@ -41,7 +40,6 @@ import org.elasticsearch.index.fielddata.ScriptDocValues;
|
|||
import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource;
|
||||
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsBuilder;
|
||||
import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -56,28 +54,27 @@ import java.util.function.Function;
|
|||
public class SortedSetOrdinalsIndexFieldData implements IndexOrdinalsFieldData {
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
private final String name;
|
||||
private final Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(ValuesSourceType valuesSourceType) {
|
||||
this(AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION, valuesSourceType);
|
||||
public Builder(String name, ValuesSourceType valuesSourceType) {
|
||||
this(name, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION, valuesSourceType);
|
||||
}
|
||||
|
||||
public Builder(Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction, ValuesSourceType valuesSourceType) {
|
||||
public Builder(String name, Function<SortedSetDocValues, ScriptDocValues<?>> scriptFunction, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.scriptFunction = scriptFunction;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSetOrdinalsIndexFieldData build(
|
||||
IndexSettings indexSettings,
|
||||
MappedFieldType fieldType,
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
final String fieldName = fieldType.name();
|
||||
return new SortedSetOrdinalsIndexFieldData(cache, fieldName, valuesSourceType, breakerService, scriptFunction);
|
||||
return new SortedSetOrdinalsIndexFieldData(cache, name, valuesSourceType, breakerService, scriptFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ public class BinaryFieldMapper extends ParametrizedFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new BytesBinaryIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new BytesBinaryIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -179,7 +179,7 @@ public class BooleanFieldMapper extends ParametrizedFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedNumericIndexFieldData.Builder(NumericType.BOOLEAN);
|
||||
return new SortedNumericIndexFieldData.Builder(name(), NumericType.BOOLEAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -434,7 +434,7 @@ public final class DateFieldMapper extends ParametrizedFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedNumericIndexFieldData.Builder(resolution.numericType());
|
||||
return new SortedNumericIndexFieldData.Builder(name(), resolution.numericType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -181,7 +181,7 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<List<P
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new AbstractLatLonPointIndexFieldData.Builder(CoreValuesSourceType.GEOPOINT);
|
||||
return new AbstractLatLonPointIndexFieldData.Builder(name(), CoreValuesSourceType.GEOPOINT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.elasticsearch.common.logging.DeprecationLogger;
|
|||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
|
@ -158,22 +157,25 @@ public class IdFieldMapper extends MetadataFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
final IndexFieldData.Builder fieldDataBuilder = new PagedBytesIndexFieldData.Builder(
|
||||
name(),
|
||||
TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY,
|
||||
TextFieldMapper.Defaults.FIELDDATA_MAX_FREQUENCY,
|
||||
TextFieldMapper.Defaults.FIELDDATA_MIN_SEGMENT_SIZE,
|
||||
CoreValuesSourceType.BYTES);
|
||||
return new IndexFieldData.Builder() {
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
public IndexFieldData<?> build(
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
if (mapperService.isIdFieldDataEnabled() == false) {
|
||||
throw new IllegalArgumentException("Fielddata access on the _id field is disallowed, "
|
||||
+ "you can re-enable it by updating the dynamic cluster setting: "
|
||||
+ IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey());
|
||||
}
|
||||
deprecationLogger.deprecatedAndMaybeLog("id_field_data", ID_FIELD_DATA_DEPRECATION_MESSAGE);
|
||||
final IndexFieldData<?> fieldData = fieldDataBuilder.build(indexSettings, fieldType, cache,
|
||||
breakerService, mapperService);
|
||||
final IndexFieldData<?> fieldData = fieldDataBuilder.build(cache, breakerService, mapperService);
|
||||
return new IndexFieldData<LeafFieldData>() {
|
||||
@Override
|
||||
public String getFieldName() {
|
||||
|
|
|
@ -104,7 +104,7 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
|||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName, CoreValuesSourceType.BYTES);
|
||||
return new ConstantIndexFieldData.Builder(mapperService -> fullyQualifiedIndexName, name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ public class IpFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(IpScriptDocValues::new, CoreValuesSourceType.IP);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), IpScriptDocValues::new, CoreValuesSourceType.IP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -279,7 +279,7 @@ public final class KeywordFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -973,7 +973,7 @@ public class NumberFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedNumericIndexFieldData.Builder(type.numericType());
|
||||
return new SortedNumericIndexFieldData.Builder(name(), type.numericType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -222,7 +222,7 @@ public class RangeFieldMapper extends FieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new BinaryIndexFieldData.Builder(CoreValuesSourceType.RANGE);
|
||||
return new BinaryIndexFieldData.Builder(name(), CoreValuesSourceType.RANGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -196,7 +196,7 @@ public class SeqNoFieldMapper extends MetadataFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedNumericIndexFieldData.Builder(NumericType.LONG);
|
||||
return new SortedNumericIndexFieldData.Builder(name(), NumericType.LONG);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -758,6 +758,7 @@ public class TextFieldMapper extends FieldMapper {
|
|||
+ "field data by uninverting the inverted index. Note that this can use significant memory.");
|
||||
}
|
||||
return new PagedBytesIndexFieldData.Builder(
|
||||
name(),
|
||||
fielddataMinFrequency,
|
||||
fielddataMaxFrequency,
|
||||
fielddataMinSegmentSize,
|
||||
|
|
|
@ -112,7 +112,7 @@ public class TypeFieldMapper extends MetadataFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
Function<MapperService, String> typeFunction = mapperService -> mapperService.documentMapper().type();
|
||||
return new ConstantIndexFieldData.Builder(typeFunction, CoreValuesSourceType.BYTES);
|
||||
return new ConstantIndexFieldData.Builder(typeFunction, name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -82,8 +82,7 @@ public class IdFieldMapperTests extends ESSingleNodeTestCase {
|
|||
mapperService.merge("type", new CompressedXContent("{\"type\":{}}"), MergeReason.MAPPING_UPDATE);
|
||||
IdFieldMapper.IdFieldType ft = (IdFieldMapper.IdFieldType) service.mapperService().fieldType("_id");
|
||||
|
||||
ft.fielddataBuilder("test").build(mapperService.getIndexSettings(),
|
||||
ft, null, null, mapperService);
|
||||
ft.fielddataBuilder("test").build(null, null, mapperService);
|
||||
assertWarnings(ID_FIELD_DATA_DEPRECATION_MESSAGE);
|
||||
|
||||
client().admin().cluster().prepareUpdateSettings()
|
||||
|
@ -91,8 +90,7 @@ public class IdFieldMapperTests extends ESSingleNodeTestCase {
|
|||
.get();
|
||||
try {
|
||||
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class,
|
||||
() -> ft.fielddataBuilder("test").build(mapperService.getIndexSettings(),
|
||||
ft, null, null, mapperService));
|
||||
() -> ft.fielddataBuilder("test").build(null, null, mapperService));
|
||||
assertThat(exc.getMessage(), containsString(IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING.getKey()));
|
||||
} finally {
|
||||
// unset cluster setting
|
||||
|
|
|
@ -447,8 +447,7 @@ public class NumberFieldTypeTests extends FieldTypeTestCase {
|
|||
|
||||
// Create an index writer configured with the same index sort.
|
||||
NumberFieldType fieldType = new NumberFieldType("field", type);
|
||||
IndexNumericFieldData fielddata = (IndexNumericFieldData) fieldType.fielddataBuilder("index")
|
||||
.build(indexSettings, fieldType, null, null, null);
|
||||
IndexNumericFieldData fielddata = (IndexNumericFieldData) fieldType.fielddataBuilder("index").build(null, null, null);
|
||||
SortField sortField = fielddata.sortField(null, MultiValueMode.MIN, null, randomBoolean());
|
||||
|
||||
IndexWriterConfig writerConfig = new IndexWriterConfig();
|
||||
|
|
|
@ -68,8 +68,8 @@ public class TypeFieldMapperTests extends ESSingleNodeTestCase {
|
|||
w.close();
|
||||
|
||||
MappedFieldType ft = mapperService.fieldType(TypeFieldMapper.NAME);
|
||||
IndexOrdinalsFieldData fd = (IndexOrdinalsFieldData) ft.fielddataBuilder("test").build(mapperService.getIndexSettings(),
|
||||
ft, new IndexFieldDataCache.None(), new NoneCircuitBreakerService(), mapperService);
|
||||
IndexOrdinalsFieldData fd = (IndexOrdinalsFieldData) ft.fielddataBuilder("test")
|
||||
.build(new IndexFieldDataCache.None(), new NoneCircuitBreakerService(), mapperService);
|
||||
LeafOrdinalsFieldData afd = fd.load(r.leaves().get(0));
|
||||
SortedSetDocValues values = afd.getOrdinalsValues();
|
||||
assertTrue(values.advanceExact(0));
|
||||
|
|
|
@ -172,8 +172,7 @@ public class QueryShardContextTests extends ESTestCase {
|
|||
|
||||
return new QueryShardContext(
|
||||
0, indexSettings, BigArrays.NON_RECYCLING_INSTANCE, null,
|
||||
(mappedFieldType, idxName) ->
|
||||
mappedFieldType.fielddataBuilder(idxName).build(indexSettings, mappedFieldType, null, null, null),
|
||||
(mappedFieldType, idxName) -> mappedFieldType.fielddataBuilder(idxName).build(null, null, null),
|
||||
mapperService, null, null, NamedXContentRegistry.EMPTY, new NamedWriteableRegistry(Collections.emptyList()),
|
||||
null, null, () -> nowInMillis, clusterAlias, null, () -> true, null);
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ public abstract class AbstractSortTestCase<T extends SortBuilder<T>> extends EST
|
|||
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(idxSettings, Mockito.mock(BitsetFilterCache.Listener.class));
|
||||
BiFunction<MappedFieldType, String, IndexFieldData<?>> indexFieldDataLookup = (fieldType, fieldIndexName) -> {
|
||||
IndexFieldData.Builder builder = fieldType.fielddataBuilder(fieldIndexName);
|
||||
return builder.build(idxSettings, fieldType, new IndexFieldDataCache.None(), null, null);
|
||||
return builder.build(new IndexFieldDataCache.None(), null, null);
|
||||
};
|
||||
return new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, bitsetFilterCache, indexFieldDataLookup,
|
||||
null, null, scriptService, xContentRegistry(), namedWriteableRegistry, null, searcher,
|
||||
|
|
|
@ -391,8 +391,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
|||
protected BiFunction<MappedFieldType, String, IndexFieldData<?>> getIndexFieldDataLookup(MapperService mapperService,
|
||||
CircuitBreakerService circuitBreakerService) {
|
||||
return (fieldType, s) -> fieldType.fielddataBuilder(mapperService.getIndexSettings().getIndex().getName())
|
||||
.build(mapperService.getIndexSettings(), fieldType,
|
||||
new IndexFieldDataCache.None(), circuitBreakerService, mapperService);
|
||||
.build(new IndexFieldDataCache.None(), circuitBreakerService, mapperService);
|
||||
|
||||
}
|
||||
|
||||
|
@ -756,8 +755,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
|||
}
|
||||
|
||||
private ValuesSourceType fieldToVST(MappedFieldType fieldType) {
|
||||
return fieldType.fielddataBuilder("")
|
||||
.build(createIndexSettings(), fieldType, null, null, null).getValuesSourceType();
|
||||
return fieldType.fielddataBuilder("").build(null, null, null).getValuesSourceType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.analytics.mapper;
|
|||
|
||||
import com.carrotsearch.hppc.DoubleArrayList;
|
||||
import com.carrotsearch.hppc.IntArrayList;
|
||||
|
||||
import org.apache.lucene.document.BinaryDocValuesField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
|
@ -28,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentSubParser;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.HistogramValue;
|
||||
import org.elasticsearch.index.fielddata.HistogramValues;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
|
@ -181,10 +181,13 @@ public class HistogramFieldMapper extends FieldMapper {
|
|||
return new IndexFieldData.Builder() {
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
public IndexFieldData<?> build(
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
|
||||
return new IndexHistogramFieldData(fieldType.name(), AnalyticsValuesSourceType.HISTOGRAM) {
|
||||
return new IndexHistogramFieldData(name(), AnalyticsValuesSourceType.HISTOGRAM) {
|
||||
|
||||
@Override
|
||||
public LeafHistogramFieldData load(LeafReaderContext context) {
|
||||
|
|
|
@ -139,7 +139,7 @@ public class ConstantKeywordFieldMapper extends FieldMapper {
|
|||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
return new ConstantIndexFieldData.Builder(mapperService -> value, CoreValuesSourceType.BYTES);
|
||||
return new ConstantIndexFieldData.Builder(mapperService -> value, name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.common.util.BigArrays;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
|
@ -320,7 +319,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new KeyedFlatObjectFieldData.Builder(key, CoreValuesSourceType.BYTES);
|
||||
return new KeyedFlatObjectFieldData.Builder(name(), key, CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -416,21 +415,18 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
|||
}
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
private final String fieldName;
|
||||
private final String key;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
Builder(String key, ValuesSourceType valuesSourceType) {
|
||||
Builder(String fieldName, String key, ValuesSourceType valuesSourceType) {
|
||||
this.fieldName = fieldName;
|
||||
this.key = key;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings,
|
||||
MappedFieldType fieldType,
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService) {
|
||||
String fieldName = fieldType.name();
|
||||
public IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
IndexOrdinalsFieldData delegate = new SortedSetOrdinalsIndexFieldData(
|
||||
cache, fieldName, valuesSourceType, breakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION);
|
||||
return new KeyedFlatObjectFieldData(key, delegate);
|
||||
|
@ -487,7 +483,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper {
|
|||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(CoreValuesSourceType.BYTES);
|
||||
return new SortedSetOrdinalsIndexFieldData.Builder(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,10 +13,8 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -95,16 +93,18 @@ public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShape
|
|||
}
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
private final String name;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
|
||||
public Builder(ValuesSourceType valuesSourceType) {
|
||||
public Builder(String name, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
public IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
// ignore breaker
|
||||
return new LatLonShapeIndexFieldData(fieldType.name(), valuesSourceType);
|
||||
return new LatLonShapeIndexFieldData(name, valuesSourceType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class GeoShapeWithDocValuesFieldMapper extends GeoShapeFieldMapper {
|
|||
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new AbstractLatLonShapeIndexFieldData.Builder(GeoShapeValuesSourceType.instance());
|
||||
return new AbstractLatLonShapeIndexFieldData.Builder(name(), GeoShapeValuesSourceType.instance());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class DenseVectorFieldMapper extends FieldMapper {
|
|||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
return new VectorIndexFieldData.Builder(true, CoreValuesSourceType.BYTES);
|
||||
return new VectorIndexFieldData.Builder(name(), true, CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -108,7 +108,7 @@ public class SparseVectorFieldMapper extends FieldMapper {
|
|||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
return new VectorIndexFieldData.Builder(false, CoreValuesSourceType.BYTES);
|
||||
return new VectorIndexFieldData.Builder(name(), false, CoreValuesSourceType.BYTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,11 +11,9 @@ import org.apache.lucene.index.LeafReaderContext;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.BigArrays;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldDataCache;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
|
@ -74,18 +72,19 @@ public class VectorIndexFieldData implements IndexFieldData<VectorDVLeafFieldDat
|
|||
}
|
||||
|
||||
public static class Builder implements IndexFieldData.Builder {
|
||||
private final String name;
|
||||
private final boolean isDense;
|
||||
private final ValuesSourceType valuesSourceType;
|
||||
public Builder(boolean isDense, ValuesSourceType valuesSourceType) {
|
||||
|
||||
public Builder(String name, boolean isDense, ValuesSourceType valuesSourceType) {
|
||||
this.name = name;
|
||||
this.isDense = isDense;
|
||||
this.valuesSourceType = valuesSourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
final String fieldName = fieldType.name();
|
||||
return new VectorIndexFieldData(fieldName, isDense, valuesSourceType);
|
||||
public IndexFieldData<?> build(IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new VectorIndexFieldData(name, isDense, valuesSourceType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.elasticsearch.common.unit.Fuzziness;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.analysis.AnalyzerScope;
|
||||
import org.elasticsearch.index.analysis.LowercaseNormalizer;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
|
@ -874,12 +873,15 @@ public class WildcardFieldMapper extends FieldMapper {
|
|||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
return new IndexFieldData.Builder() {
|
||||
|
||||
@Override
|
||||
public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService, MapperService mapperService) {
|
||||
return new StringBinaryIndexFieldData(fieldType.name(), CoreValuesSourceType.BYTES);
|
||||
}};
|
||||
public IndexFieldData<?> build(
|
||||
IndexFieldDataCache cache,
|
||||
CircuitBreakerService breakerService,
|
||||
MapperService mapperService
|
||||
) {
|
||||
return new StringBinaryIndexFieldData(name(), CoreValuesSourceType.BYTES);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -789,7 +789,7 @@ public class WildcardFieldMapperTests extends ESTestCase {
|
|||
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(idxSettings, Mockito.mock(BitsetFilterCache.Listener.class));
|
||||
BiFunction<MappedFieldType, String, IndexFieldData<?>> indexFieldDataLookup = (fieldType, fieldIndexName) -> {
|
||||
IndexFieldData.Builder builder = fieldType.fielddataBuilder(fieldIndexName);
|
||||
return builder.build(idxSettings, fieldType, new IndexFieldDataCache.None(), null, null);
|
||||
return builder.build(new IndexFieldDataCache.None(), null, null);
|
||||
};
|
||||
return new QueryShardContext(0, idxSettings, BigArrays.NON_RECYCLING_INSTANCE, bitsetFilterCache, indexFieldDataLookup,
|
||||
null, null, null, xContentRegistry(), null, null, null,
|
||||
|
|
Loading…
Reference in New Issue