Rename MapperService#fullName to fieldType.

The new name more accurately describes what the method returns.
This commit is contained in:
Julie Tibshirani 2020-02-07 10:24:01 -08:00
parent bc3ef9b8df
commit 337d73a7c6
86 changed files with 242 additions and 244 deletions

View File

@ -282,7 +282,7 @@ public abstract class ArrayValuesSourceAggregationBuilder<VS extends ValuesSourc
return config.format(resolveFormat(format, valueType)); return config.format(resolveFormat(format, valueType));
} }
MappedFieldType fieldType = queryShardContext.getMapperService().fullName(field); MappedFieldType fieldType = queryShardContext.getMapperService().fieldType(field);
if (fieldType == null) { if (fieldType == null) {
ValuesSourceType valuesSourceType = valueType != null ? valueType.getValuesSourceType() : this.valuesSourceType; ValuesSourceType valuesSourceType = valueType != null ? valueType.getValuesSourceType() : this.valuesSourceType;
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType); ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);

View File

@ -461,7 +461,7 @@ public class ExpressionScriptEngine implements ScriptEngine {
} }
String fieldname = parts[1].text; String fieldname = parts[1].text;
MappedFieldType fieldType = lookup.doc().mapperService().fullName(fieldname); MappedFieldType fieldType = lookup.doc().mapperService().fieldType(fieldname);
if (fieldType == null) { if (fieldType == null) {
throw new ParseException("Field [" + fieldname + "] does not exist in mappings", 5); throw new ParseException("Field [" + fieldname + "] does not exist in mappings", 5);

View File

@ -49,8 +49,8 @@ public class ExpressionFieldScriptTests extends ESTestCase {
NumberFieldMapper.NumberFieldType fieldType = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE); NumberFieldMapper.NumberFieldType fieldType = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.DOUBLE);
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName("field")).thenReturn(fieldType); when(mapperService.fieldType("field")).thenReturn(fieldType);
when(mapperService.fullName("alias")).thenReturn(fieldType); when(mapperService.fieldType("alias")).thenReturn(fieldType);
SortedNumericDoubleValues doubleValues = mock(SortedNumericDoubleValues.class); SortedNumericDoubleValues doubleValues = mock(SortedNumericDoubleValues.class);
when(doubleValues.advanceExact(anyInt())).thenReturn(true); when(doubleValues.advanceExact(anyInt())).thenReturn(true);

View File

@ -48,8 +48,8 @@ public class ExpressionNumberSortScriptTests extends ESTestCase {
NumberFieldType fieldType = new NumberFieldType(NumberType.DOUBLE); NumberFieldType fieldType = new NumberFieldType(NumberType.DOUBLE);
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName("field")).thenReturn(fieldType); when(mapperService.fieldType("field")).thenReturn(fieldType);
when(mapperService.fullName("alias")).thenReturn(fieldType); when(mapperService.fieldType("alias")).thenReturn(fieldType);
SortedNumericDoubleValues doubleValues = mock(SortedNumericDoubleValues.class); SortedNumericDoubleValues doubleValues = mock(SortedNumericDoubleValues.class);
when(doubleValues.advanceExact(anyInt())).thenReturn(true); when(doubleValues.advanceExact(anyInt())).thenReturn(true);

View File

@ -48,8 +48,8 @@ public class ExpressionTermsSetQueryTests extends ESTestCase {
NumberFieldType fieldType = new NumberFieldType(NumberType.DOUBLE); NumberFieldType fieldType = new NumberFieldType(NumberType.DOUBLE);
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName("field")).thenReturn(fieldType); when(mapperService.fieldType("field")).thenReturn(fieldType);
when(mapperService.fullName("alias")).thenReturn(fieldType); when(mapperService.fieldType("alias")).thenReturn(fieldType);
SortedNumericDoubleValues doubleValues = mock(SortedNumericDoubleValues.class); SortedNumericDoubleValues doubleValues = mock(SortedNumericDoubleValues.class);
when(doubleValues.advanceExact(anyInt())).thenReturn(true); when(doubleValues.advanceExact(anyInt())).thenReturn(true);

View File

@ -75,7 +75,7 @@ public class RankFeatureMetaFieldMapper extends MetadataFieldMapper {
@Override @Override
public MetadataFieldMapper.Builder<?,?> parse(String name, public MetadataFieldMapper.Builder<?,?> parse(String name,
Map<String, Object> node, ParserContext parserContext) throws MapperParsingException { Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
return new Builder(parserContext.mapperService().fullName(NAME)); return new Builder(parserContext.mapperService().fieldType(NAME));
} }
@Override @Override

View File

@ -258,14 +258,14 @@ public class SearchAsYouTypeFieldMapperTests extends ESSingleNodeTestCase {
fields.add(path); fields.add(path);
final MapperService mapperService = final MapperService mapperService =
createIndex(index, Settings.EMPTY, "_doc", mapping).mapperService(); createIndex(index, Settings.EMPTY, "_doc", mapping).mapperService();
FieldType fieldType = mapperService.fullName(path + "._index_prefix"); FieldType fieldType = mapperService.fieldType(path + "._index_prefix");
assertThat(fieldType, instanceOf(PrefixFieldType.class)); assertThat(fieldType, instanceOf(PrefixFieldType.class));
PrefixFieldType prefixFieldType = (PrefixFieldType) fieldType; PrefixFieldType prefixFieldType = (PrefixFieldType) fieldType;
assertEquals(path, prefixFieldType.parentField); assertEquals(path, prefixFieldType.parentField);
for (int i = 2; i < shingleSize; i++) { for (int i = 2; i < shingleSize; i++) {
String name = path + "._" + i + "gram"; String name = path + "._" + i + "gram";
fields.add(name); fields.add(name);
fieldType = mapperService.fullName(name); fieldType = mapperService.fieldType(name);
assertThat(fieldType, instanceOf(ShingleFieldType.class)); assertThat(fieldType, instanceOf(ShingleFieldType.class));
ShingleFieldType ft = (ShingleFieldType) fieldType; ShingleFieldType ft = (ShingleFieldType) fieldType;
assertEquals(i, ft.shingleSize); assertEquals(i, ft.shingleSize);

View File

@ -83,7 +83,7 @@ public final class ParentJoinFieldMapper extends FieldMapper {
*/ */
public static ParentJoinFieldMapper getMapper(MapperService service) { public static ParentJoinFieldMapper getMapper(MapperService service) {
MetaJoinFieldMapper.MetaJoinFieldType fieldType = MetaJoinFieldMapper.MetaJoinFieldType fieldType =
(MetaJoinFieldMapper.MetaJoinFieldType) service.fullName(MetaJoinFieldMapper.NAME); (MetaJoinFieldMapper.MetaJoinFieldType) service.fieldType(MetaJoinFieldMapper.NAME);
return fieldType == null ? null : fieldType.getMapper(); return fieldType == null ? null : fieldType.getMapper();
} }

View File

@ -131,7 +131,7 @@ class ParentChildInnerHitContextBuilder extends InnerHitContextBuilder {
result[i] = new TopDocsAndMaxScore(Lucene.EMPTY_TOP_DOCS, Float.NaN); result[i] = new TopDocsAndMaxScore(Lucene.EMPTY_TOP_DOCS, Float.NaN);
continue; continue;
} }
q = context.mapperService().fullName(IdFieldMapper.NAME).termQuery(parentId, qsc); q = context.mapperService().fieldType(IdFieldMapper.NAME).termQuery(parentId, qsc);
} }
Weight weight = context.searcher().createWeight(context.searcher().rewrite(q), ScoreMode.COMPLETE_NO_SCORES, 1f); Weight weight = context.searcher().createWeight(context.searcher().rewrite(q), ScoreMode.COMPLETE_NO_SCORES, 1f);

View File

@ -277,7 +277,7 @@ public class ChildrenToParentAggregatorTests extends AggregatorTestCase {
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
MetaJoinFieldMapper.MetaJoinFieldType metaJoinFieldType = mock(MetaJoinFieldMapper.MetaJoinFieldType.class); MetaJoinFieldMapper.MetaJoinFieldType metaJoinFieldType = mock(MetaJoinFieldMapper.MetaJoinFieldType.class);
when(metaJoinFieldType.getMapper()).thenReturn(joinFieldMapper); when(metaJoinFieldType.getMapper()).thenReturn(joinFieldMapper);
when(mapperService.fullName("_parent_join")).thenReturn(metaJoinFieldType); when(mapperService.fieldType("_parent_join")).thenReturn(metaJoinFieldType);
return mapperService; return mapperService;
} }

View File

@ -165,7 +165,7 @@ public class ParentToChildrenAggregatorTests extends AggregatorTestCase {
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
MetaJoinFieldMapper.MetaJoinFieldType metaJoinFieldType = mock(MetaJoinFieldMapper.MetaJoinFieldType.class); MetaJoinFieldMapper.MetaJoinFieldType metaJoinFieldType = mock(MetaJoinFieldMapper.MetaJoinFieldType.class);
when(metaJoinFieldType.getMapper()).thenReturn(joinFieldMapper); when(metaJoinFieldType.getMapper()).thenReturn(joinFieldMapper);
when(mapperService.fullName("_parent_join")).thenReturn(metaJoinFieldType); when(mapperService.fieldType("_parent_join")).thenReturn(metaJoinFieldType);
return mapperService; return mapperService;
} }

View File

@ -446,11 +446,11 @@ public class ParentJoinFieldMapperTests extends ESSingleNodeTestCase {
DocumentMapper docMapper = service.mapperService().merge("type", new CompressedXContent(mapping), DocumentMapper docMapper = service.mapperService().merge("type", new CompressedXContent(mapping),
MapperService.MergeReason.MAPPING_UPDATE); MapperService.MergeReason.MAPPING_UPDATE);
assertTrue(docMapper.mappers().getMapper("join_field") == ParentJoinFieldMapper.getMapper(service.mapperService())); assertTrue(docMapper.mappers().getMapper("join_field") == ParentJoinFieldMapper.getMapper(service.mapperService()));
assertFalse(service.mapperService().fullName("join_field").eagerGlobalOrdinals()); assertFalse(service.mapperService().fieldType("join_field").eagerGlobalOrdinals());
assertNotNull(service.mapperService().fullName("join_field#parent")); assertNotNull(service.mapperService().fieldType("join_field#parent"));
assertTrue(service.mapperService().fullName("join_field#parent").eagerGlobalOrdinals()); assertTrue(service.mapperService().fieldType("join_field#parent").eagerGlobalOrdinals());
assertNotNull(service.mapperService().fullName("join_field#child")); assertNotNull(service.mapperService().fieldType("join_field#child"));
assertTrue(service.mapperService().fullName("join_field#child").eagerGlobalOrdinals()); assertTrue(service.mapperService().fieldType("join_field#child").eagerGlobalOrdinals());
mapping = Strings.toString(XContentFactory.jsonBuilder().startObject() mapping = Strings.toString(XContentFactory.jsonBuilder().startObject()
.startObject("properties") .startObject("properties")
@ -466,10 +466,10 @@ public class ParentJoinFieldMapperTests extends ESSingleNodeTestCase {
.endObject()); .endObject());
service.mapperService().merge("type", new CompressedXContent(mapping), service.mapperService().merge("type", new CompressedXContent(mapping),
MapperService.MergeReason.MAPPING_UPDATE); MapperService.MergeReason.MAPPING_UPDATE);
assertFalse(service.mapperService().fullName("join_field").eagerGlobalOrdinals()); assertFalse(service.mapperService().fieldType("join_field").eagerGlobalOrdinals());
assertNotNull(service.mapperService().fullName("join_field#parent")); assertNotNull(service.mapperService().fieldType("join_field#parent"));
assertFalse(service.mapperService().fullName("join_field#parent").eagerGlobalOrdinals()); assertFalse(service.mapperService().fieldType("join_field#parent").eagerGlobalOrdinals());
assertNotNull(service.mapperService().fullName("join_field#child")); assertNotNull(service.mapperService().fieldType("join_field#child"));
assertFalse(service.mapperService().fullName("join_field#child").eagerGlobalOrdinals()); assertFalse(service.mapperService().fieldType("join_field#child").eagerGlobalOrdinals());
} }
} }

View File

@ -197,7 +197,7 @@ public class CandidateQueryTests extends ESSingleNodeTestCase {
} }
Collections.sort(intValues); Collections.sort(intValues);
MappedFieldType intFieldType = mapperService.fullName("int_field"); MappedFieldType intFieldType = mapperService.fieldType("int_field");
List<Supplier<Query>> queryFunctions = new ArrayList<>(); List<Supplier<Query>> queryFunctions = new ArrayList<>();
queryFunctions.add(MatchNoDocsQuery::new); queryFunctions.add(MatchNoDocsQuery::new);
@ -329,7 +329,7 @@ public class CandidateQueryTests extends ESSingleNodeTestCase {
stringValues.add("value2"); stringValues.add("value2");
stringValues.add("value3"); stringValues.add("value3");
MappedFieldType intFieldType = mapperService.fullName("int_field"); MappedFieldType intFieldType = mapperService.fieldType("int_field");
List<int[]> ranges = new ArrayList<>(); List<int[]> ranges = new ArrayList<>();
ranges.add(new int[]{-5, 5}); ranges.add(new int[]{-5, 5});
ranges.add(new int[]{0, 10}); ranges.add(new int[]{0, 10});

View File

@ -170,7 +170,7 @@ public class PercolatorFieldMapperTests extends ESSingleNodeTestCase {
.startObject("properties").startObject(fieldName).field("type", "percolator").endObject().endObject() .startObject("properties").startObject(fieldName).field("type", "percolator").endObject().endObject()
.endObject().endObject()); .endObject().endObject());
mapperService.merge("doc", new CompressedXContent(percolatorMapper), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("doc", new CompressedXContent(percolatorMapper), MapperService.MergeReason.MAPPING_UPDATE);
fieldType = (PercolatorFieldMapper.FieldType) mapperService.fullName(fieldName); fieldType = (PercolatorFieldMapper.FieldType) mapperService.fieldType(fieldName);
} }
public void testExtractTerms() throws Exception { public void testExtractTerms() throws Exception {
@ -229,10 +229,10 @@ public class PercolatorFieldMapperTests extends ESSingleNodeTestCase {
public void testExtractRanges() throws Exception { public void testExtractRanges() throws Exception {
addQueryFieldMappings(); addQueryFieldMappings();
BooleanQuery.Builder bq = new BooleanQuery.Builder(); BooleanQuery.Builder bq = new BooleanQuery.Builder();
Query rangeQuery1 = mapperService.fullName("number_field1") Query rangeQuery1 = mapperService.fieldType("number_field1")
.rangeQuery(10, 20, true, true, null, null, null, null); .rangeQuery(10, 20, true, true, null, null, null, null);
bq.add(rangeQuery1, Occur.MUST); bq.add(rangeQuery1, Occur.MUST);
Query rangeQuery2 = mapperService.fullName("number_field1") Query rangeQuery2 = mapperService.fieldType("number_field1")
.rangeQuery(15, 20, true, true, null, null, null, null); .rangeQuery(15, 20, true, true, null, null, null, null);
bq.add(rangeQuery2, Occur.MUST); bq.add(rangeQuery2, Occur.MUST);
@ -264,7 +264,7 @@ public class PercolatorFieldMapperTests extends ESSingleNodeTestCase {
// Range queries on different fields: // Range queries on different fields:
bq = new BooleanQuery.Builder(); bq = new BooleanQuery.Builder();
bq.add(rangeQuery1, Occur.MUST); bq.add(rangeQuery1, Occur.MUST);
rangeQuery2 = mapperService.fullName("number_field2") rangeQuery2 = mapperService.fieldType("number_field2")
.rangeQuery(15, 20, true, true, null, null, null, null); .rangeQuery(15, 20, true, true, null, null, null, null);
bq.add(rangeQuery2, Occur.MUST); bq.add(rangeQuery2, Occur.MUST);

View File

@ -90,7 +90,7 @@ public class SizeFieldMapper extends MetadataFieldMapper {
@Override @Override
public MetadataFieldMapper.Builder<?, ?> parse(String name, Map<String, Object> node, public MetadataFieldMapper.Builder<?, ?> parse(String name, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException { ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.mapperService().fullName(NAME), Builder builder = new Builder(parserContext.mapperService().fieldType(NAME),
parserContext.indexVersionCreated()); parserContext.indexVersionCreated());
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) { for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next(); Map.Entry<String, Object> entry = iterator.next();

View File

@ -177,7 +177,7 @@ public class TransportAnalyzeAction extends TransportSingleShardAction<AnalyzeAc
if (indexService == null) { if (indexService == null) {
throw new IllegalArgumentException("analysis based on a specific field requires an index"); throw new IllegalArgumentException("analysis based on a specific field requires an index");
} }
MappedFieldType fieldType = indexService.mapperService().fullName(request.field()); MappedFieldType fieldType = indexService.mapperService().fieldType(request.field());
if (fieldType != null) { if (fieldType != null) {
if (fieldType.tokenized() || fieldType instanceof KeywordFieldMapper.KeywordFieldType) { if (fieldType.tokenized() || fieldType instanceof KeywordFieldMapper.KeywordFieldType) {
return fieldType.indexAnalyzer(); return fieldType.indexAnalyzer();

View File

@ -83,7 +83,7 @@ public class TransportFieldCapabilitiesIndexAction extends TransportSingleShardA
Predicate<String> fieldPredicate = indicesService.getFieldFilter().apply(shardId.getIndexName()); Predicate<String> fieldPredicate = indicesService.getFieldFilter().apply(shardId.getIndexName());
Map<String, IndexFieldCapabilities> responseMap = new HashMap<>(); Map<String, IndexFieldCapabilities> responseMap = new HashMap<>();
for (String field : fieldNames) { for (String field : fieldNames) {
MappedFieldType ft = mapperService.fullName(field); MappedFieldType ft = mapperService.fieldType(field);
if (ft != null) { if (ft != null) {
if (indicesService.isMetaDataField(mapperService.getIndexSettings().getIndexVersionCreated(), field) if (indicesService.isMetaDataField(mapperService.getIndexSettings().getIndexVersionCreated(), field)
|| fieldPredicate.test(ft.name())) { || fieldPredicate.test(ft.name())) {
@ -102,7 +102,7 @@ public class TransportFieldCapabilitiesIndexAction extends TransportSingleShardA
break; break;
} }
// checks if the parent field contains sub-fields // checks if the parent field contains sub-fields
if (mapperService.fullName(parentField) == null) { if (mapperService.fieldType(parentField) == null) {
// no field type, it must be an object field // no field type, it must be an object field
ObjectMapper mapper = mapperService.getObjectMapper(parentField); ObjectMapper mapper = mapperService.getObjectMapper(parentField);
String type = mapper.nested().isNested() ? "nested" : "object"; String type = mapper.nested().isNested() ? "nested" : "object";

View File

@ -184,7 +184,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
// we delay the actual creation of the sort order for this index because the mapping has not been merged yet. // we delay the actual creation of the sort order for this index because the mapping has not been merged yet.
// The sort order is validated right after the merge of the mapping later in the process. // The sort order is validated right after the merge of the mapping later in the process.
this.indexSortSupplier = () -> indexSettings.getIndexSortConfig().buildIndexSort( this.indexSortSupplier = () -> indexSettings.getIndexSortConfig().buildIndexSort(
mapperService::fullName, mapperService::fieldType,
indexFieldData::getForField indexFieldData::getForField
); );
} else { } else {

View File

@ -54,7 +54,7 @@ public class PerFieldMappingPostingFormatCodec extends Lucene84Codec {
@Override @Override
public PostingsFormat getPostingsFormatForField(String field) { public PostingsFormat getPostingsFormatForField(String field) {
final MappedFieldType fieldType = mapperService.fullName(field); final MappedFieldType fieldType = mapperService.fieldType(field);
if (fieldType == null) { if (fieldType == null) {
logger.warn("no index mapper found for field: [{}] returning default postings format", field); logger.warn("no index mapper found for field: [{}] returning default postings format", field);
} else if (fieldType instanceof CompletionFieldMapper.CompletionFieldType) { } else if (fieldType instanceof CompletionFieldMapper.CompletionFieldType) {

View File

@ -94,7 +94,7 @@ public class FieldsVisitor extends StoredFieldVisitor {
type = mapper.type(); type = mapper.type();
} }
for (Map.Entry<String, List<Object>> entry : fields().entrySet()) { for (Map.Entry<String, List<Object>> entry : fields().entrySet()) {
MappedFieldType fieldType = mapperService.fullName(entry.getKey()); MappedFieldType fieldType = mapperService.fieldType(entry.getKey());
if (fieldType == null) { if (fieldType == null) {
throw new IllegalStateException("Field [" + entry.getKey() throw new IllegalStateException("Field [" + entry.getKey()
+ "] exists in the index but not in mappings"); + "] exists in the index but not in mappings");

View File

@ -77,7 +77,7 @@ public class AllFieldMapper extends MetadataFieldMapper {
@Override @Override
public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node, public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException { ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.mapperService().fullName(NAME)); Builder builder = new Builder(parserContext.mapperService().fieldType(NAME));
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) { for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next(); Map.Entry<String, Object> entry = iterator.next();
String fieldName = entry.getKey(); String fieldName = entry.getKey();

View File

@ -71,7 +71,7 @@ public final class DocumentFieldMappers implements Iterable<Mapper> {
* Returns the leaf mapper associated with this field name. Note that the returned mapper * Returns the leaf mapper associated with this field name. Note that the returned mapper
* could be either a concrete {@link FieldMapper}, or a {@link FieldAliasMapper}. * could be either a concrete {@link FieldMapper}, or a {@link FieldAliasMapper}.
* *
* To access a field's type information, {@link MapperService#fullName} should be used instead. * To access a field's type information, {@link MapperService#fieldType} should be used instead.
*/ */
public Mapper getMapper(String field) { public Mapper getMapper(String field) {
return fieldMappers.get(field); return fieldMappers.get(field);

View File

@ -85,7 +85,7 @@ public class DocumentMapper implements ToXContentFragment {
final MetadataFieldMapper metadataMapper; final MetadataFieldMapper metadataMapper;
if (existingMetadataMapper == null) { if (existingMetadataMapper == null) {
final TypeParser parser = entry.getValue(); final TypeParser parser = entry.getValue();
metadataMapper = parser.getDefault(mapperService.fullName(name), metadataMapper = parser.getDefault(mapperService.fieldType(name),
mapperService.documentMapperParser().parserContext()); mapperService.documentMapperParser().parserContext());
} else { } else {
metadataMapper = existingMetadataMapper; metadataMapper = existingMetadataMapper;

View File

@ -819,7 +819,7 @@ final class DocumentParser {
} }
final String path = context.path().pathAsText(currentFieldName); final String path = context.path().pathAsText(currentFieldName);
final Mapper.BuilderContext builderContext = new Mapper.BuilderContext(context.indexSettings().getSettings(), context.path()); final Mapper.BuilderContext builderContext = new Mapper.BuilderContext(context.indexSettings().getSettings(), context.path());
final MappedFieldType existingFieldType = context.mapperService().fullName(path); final MappedFieldType existingFieldType = context.mapperService().fieldType(path);
final Mapper.Builder builder; final Mapper.Builder builder;
if (existingFieldType != null) { if (existingFieldType != null) {
// create a builder of the same type // create a builder of the same type

View File

@ -104,7 +104,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper {
@Override @Override
public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node, public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException { ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.mapperService().fullName(NAME)); Builder builder = new Builder(parserContext.mapperService().fieldType(NAME));
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) { for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next(); Map.Entry<String, Object> entry = iterator.next();

View File

@ -75,7 +75,7 @@ public final class IgnoredFieldMapper extends MetadataFieldMapper {
@Override @Override
public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node, public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException { ParserContext parserContext) throws MapperParsingException {
return new Builder(parserContext.mapperService().fullName(NAME)); return new Builder(parserContext.mapperService().fieldType(NAME));
} }
@Override @Override

View File

@ -750,11 +750,9 @@ public class MapperService extends AbstractIndexComponent implements Closeable {
} }
/** /**
* Returns the {@link MappedFieldType} for the give fullName. * Given the full name of a field, returns its {@link MappedFieldType}.
*
* If multiple types have fields with the same full name, the first is returned.
*/ */
public MappedFieldType fullName(String fullName) { public MappedFieldType fieldType(String fullName) {
return fieldTypes.get(fullName); return fieldTypes.get(fullName);
} }
@ -858,7 +856,7 @@ public class MapperService extends AbstractIndexComponent implements Closeable {
@Override @Override
protected Analyzer getWrappedAnalyzer(String fieldName) { protected Analyzer getWrappedAnalyzer(String fieldName) {
MappedFieldType fieldType = fullName(fieldName); MappedFieldType fieldType = fieldType(fieldName);
if (fieldType != null) { if (fieldType != null) {
Analyzer analyzer = extractAnalyzer.apply(fieldType); Analyzer analyzer = extractAnalyzer.apply(fieldType);
if (analyzer != null) { if (analyzer != null) {

View File

@ -84,7 +84,7 @@ public class RoutingFieldMapper extends MetadataFieldMapper {
@Override @Override
public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node, public MetadataFieldMapper.Builder<?,?> parse(String name, Map<String, Object> node,
ParserContext parserContext) throws MapperParsingException { ParserContext parserContext) throws MapperParsingException {
Builder builder = new Builder(parserContext.mapperService().fullName(NAME)); Builder builder = new Builder(parserContext.mapperService().fieldType(NAME));
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) { for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next(); Map.Entry<String, Object> entry = iterator.next();
String fieldName = entry.getKey(); String fieldName = entry.getKey();

View File

@ -133,7 +133,7 @@ public class ExistsQueryBuilder extends AbstractQueryBuilder<ExistsQueryBuilder>
public static Query newFilter(QueryShardContext context, String fieldPattern) { public static Query newFilter(QueryShardContext context, String fieldPattern) {
final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldMapper.FieldNamesFieldType) context final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldMapper.FieldNamesFieldType) context
.getMapperService().fullName(FieldNamesFieldMapper.NAME); .getMapperService().fieldType(FieldNamesFieldMapper.NAME);
if (fieldNamesFieldType == null) { if (fieldNamesFieldType == null) {
// can only happen when no types exist, so no docs exist either // can only happen when no types exist, so no docs exist either
return Queries.newMatchNoDocsQuery("Missing types in \"" + NAME + "\" query."); return Queries.newMatchNoDocsQuery("Missing types in \"" + NAME + "\" query.");
@ -187,7 +187,7 @@ public class ExistsQueryBuilder extends AbstractQueryBuilder<ExistsQueryBuilder>
} }
private static Query newFieldExistsQuery(QueryShardContext context, String field) { private static Query newFieldExistsQuery(QueryShardContext context, String field) {
MappedFieldType fieldType = context.getMapperService().fullName(field); MappedFieldType fieldType = context.getMapperService().fieldType(field);
if (fieldType == null) { if (fieldType == null) {
// The field does not exist as a leaf but could be an object so // The field does not exist as a leaf but could be an object so
// check for an object mapper // check for an object mapper
@ -204,7 +204,7 @@ public class ExistsQueryBuilder extends AbstractQueryBuilder<ExistsQueryBuilder>
BooleanQuery.Builder booleanQuery = new BooleanQuery.Builder(); BooleanQuery.Builder booleanQuery = new BooleanQuery.Builder();
Collection<String> fields = context.simpleMatchToIndexNames(objField + ".*"); Collection<String> fields = context.simpleMatchToIndexNames(objField + ".*");
for (String field : fields) { for (String field : fields) {
Query existsQuery = context.getMapperService().fullName(field).existsQuery(context); Query existsQuery = context.getMapperService().fieldType(field).existsQuery(context);
booleanQuery.add(existsQuery, Occur.SHOULD); booleanQuery.add(existsQuery, Occur.SHOULD);
} }
return new ConstantScoreQuery(booleanQuery.build()); return new ConstantScoreQuery(booleanQuery.build());

View File

@ -235,7 +235,7 @@ public class QueryShardContext extends QueryRewriteContext {
if (name.equals(TypeFieldMapper.NAME)) { if (name.equals(TypeFieldMapper.NAME)) {
deprecationLogger.deprecatedAndMaybeLog("query_with_types", TYPES_DEPRECATION_MESSAGE); deprecationLogger.deprecatedAndMaybeLog("query_with_types", TYPES_DEPRECATION_MESSAGE);
} }
return failIfFieldMappingNotFound(name, mapperService.fullName(name)); return failIfFieldMappingNotFound(name, mapperService.fieldType(name));
} }
public ObjectMapper getObjectMapper(String name) { public ObjectMapper getObjectMapper(String name) {

View File

@ -438,7 +438,7 @@ public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> i
return MappedFieldType.Relation.INTERSECTS; return MappedFieldType.Relation.INTERSECTS;
} }
final MapperService mapperService = shardContext.getMapperService(); final MapperService mapperService = shardContext.getMapperService();
final MappedFieldType fieldType = mapperService.fullName(fieldName); final MappedFieldType fieldType = mapperService.fieldType(fieldName);
if (fieldType == null) { if (fieldType == null) {
// no field means we have no values // no field means we have no values
return MappedFieldType.Relation.DISJOINT; return MappedFieldType.Relation.DISJOINT;
@ -491,7 +491,7 @@ public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> i
* if the {@link FieldNamesFieldMapper} is enabled. * if the {@link FieldNamesFieldMapper} is enabled.
*/ */
final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType = final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType =
(FieldNamesFieldMapper.FieldNamesFieldType) context.getMapperService().fullName(FieldNamesFieldMapper.NAME); (FieldNamesFieldMapper.FieldNamesFieldType) context.getMapperService().fieldType(FieldNamesFieldMapper.NAME);
if (fieldNamesFieldType == null) { if (fieldNamesFieldType == null) {
return new MatchNoDocsQuery("No mappings yet"); return new MatchNoDocsQuery("No mappings yet");
} }

View File

@ -144,7 +144,7 @@ public class FieldValueFactorFunctionBuilder extends ScoreFunctionBuilder<FieldV
@Override @Override
protected ScoreFunction doToFunction(QueryShardContext context) { protected ScoreFunction doToFunction(QueryShardContext context) {
MappedFieldType fieldType = context.getMapperService().fullName(field); MappedFieldType fieldType = context.getMapperService().fieldType(field);
IndexNumericFieldData fieldData = null; IndexNumericFieldData fieldData = null;
if (fieldType == null) { if (fieldType == null) {
if(missing == null) { if(missing == null) {

View File

@ -166,11 +166,11 @@ public class RandomScoreFunctionBuilder extends ScoreFunctionBuilder<RandomScore
} else { } else {
final MappedFieldType fieldType; final MappedFieldType fieldType;
if (field != null) { if (field != null) {
fieldType = context.getMapperService().fullName(field); fieldType = context.getMapperService().fieldType(field);
} else { } else {
deprecationLogger.deprecated( deprecationLogger.deprecated(
"As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"); "As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set");
fieldType = context.getMapperService().fullName(IdFieldMapper.NAME); fieldType = context.getMapperService().fieldType(IdFieldMapper.NAME);
} }
if (fieldType == null) { if (fieldType == null) {
if (context.getMapperService().documentMapper() == null) { if (context.getMapperService().documentMapper() == null) {

View File

@ -103,7 +103,7 @@ public final class NestedHelper {
// we might add a nested filter when it is nor required. // we might add a nested filter when it is nor required.
return true; return true;
} }
if (mapperService.fullName(field) == null) { if (mapperService.fieldType(field) == null) {
// field does not exist // field does not exist
return false; return false;
} }
@ -172,7 +172,7 @@ public final class NestedHelper {
// we might add a nested filter when it is nor required. // we might add a nested filter when it is nor required.
return true; return true;
} }
if (mapperService.fullName(field) == null) { if (mapperService.fieldType(field) == null) {
return false; return false;
} }
for (String parent = parentObject(field); parent != null; parent = parentObject(parent)) { for (String parent = parentObject(field); parent != null; parent = parentObject(parent)) {

View File

@ -140,7 +140,7 @@ public final class QueryParserHelper {
fieldName = fieldName + fieldSuffix; fieldName = fieldName + fieldSuffix;
} }
MappedFieldType fieldType = context.getMapperService().fullName(fieldName); MappedFieldType fieldType = context.getMapperService().fieldType(fieldName);
if (fieldType == null) { if (fieldType == null) {
continue; continue;
} }

View File

@ -613,7 +613,7 @@ public class QueryStringQueryParser extends XQueryParser {
private Query existsQuery(String fieldName) { private Query existsQuery(String fieldName) {
final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType = final FieldNamesFieldMapper.FieldNamesFieldType fieldNamesFieldType =
(FieldNamesFieldMapper.FieldNamesFieldType) context.getMapperService().fullName(FieldNamesFieldMapper.NAME); (FieldNamesFieldMapper.FieldNamesFieldType) context.getMapperService().fieldType(FieldNamesFieldMapper.NAME);
if (fieldNamesFieldType == null) { if (fieldNamesFieldType == null) {
return new MatchNoDocsQuery("No mappings yet"); return new MatchNoDocsQuery("No mappings yet");
} }

View File

@ -191,7 +191,7 @@ public final class SimilarityService extends AbstractIndexComponent {
@Override @Override
public Similarity get(String name) { public Similarity get(String name) {
MappedFieldType fieldType = mapperService.fullName(name); MappedFieldType fieldType = mapperService.fieldType(name);
return (fieldType != null && fieldType.similarity() != null) ? fieldType.similarity().get() : defaultSimilarity; return (fieldType != null && fieldType.similarity() != null) ? fieldType.similarity().get() : defaultSimilarity;
} }
} }

View File

@ -195,7 +195,7 @@ public class TermVectorsService {
/* only keep valid fields */ /* only keep valid fields */
Set<String> validFields = new HashSet<>(); Set<String> validFields = new HashSet<>();
for (String field : selectedFields) { for (String field : selectedFields) {
MappedFieldType fieldType = indexShard.mapperService().fullName(field); MappedFieldType fieldType = indexShard.mapperService().fieldType(field);
if (!isValidField(fieldType)) { if (!isValidField(fieldType)) {
continue; continue;
} }
@ -233,7 +233,7 @@ public class TermVectorsService {
if (perFieldAnalyzer != null && perFieldAnalyzer.containsKey(field)) { if (perFieldAnalyzer != null && perFieldAnalyzer.containsKey(field)) {
analyzer = mapperService.getIndexAnalyzers().get(perFieldAnalyzer.get(field).toString()); analyzer = mapperService.getIndexAnalyzers().get(perFieldAnalyzer.get(field).toString());
} else { } else {
MappedFieldType fieldType = mapperService.fullName(field); MappedFieldType fieldType = mapperService.fieldType(field);
analyzer = fieldType.indexAnalyzer(); analyzer = fieldType.indexAnalyzer();
} }
if (analyzer == null) { if (analyzer == null) {
@ -303,7 +303,7 @@ public class TermVectorsService {
Set<String> seenFields = new HashSet<>(); Set<String> seenFields = new HashSet<>();
Collection<DocumentField> documentFields = new HashSet<>(); Collection<DocumentField> documentFields = new HashSet<>();
for (IndexableField field : doc.getFields()) { for (IndexableField field : doc.getFields()) {
MappedFieldType fieldType = indexShard.mapperService().fullName(field.name()); MappedFieldType fieldType = indexShard.mapperService().fieldType(field.name());
if (!isValidField(fieldType)) { if (!isValidField(fieldType)) {
continue; continue;
} }

View File

@ -308,7 +308,7 @@ final class DefaultSearchContext extends SearchContext {
private Query createTypeFilter(String[] types) { private Query createTypeFilter(String[] types) {
if (types != null && types.length >= 1) { if (types != null && types.length >= 1) {
MappedFieldType ft = mapperService().fullName(TypeFieldMapper.NAME); MappedFieldType ft = mapperService().fieldType(TypeFieldMapper.NAME);
if (ft != null) { if (ft != null) {
// ft might be null if no documents have been indexed yet // ft might be null if no documents have been indexed yet
return ft.termsQuery(Arrays.asList(types), queryShardContext); return ft.termsQuery(Arrays.asList(types), queryShardContext);
@ -800,7 +800,7 @@ final class DefaultSearchContext extends SearchContext {
@Override @Override
public MappedFieldType smartNameFieldType(String name) { public MappedFieldType smartNameFieldType(String name) {
return mapperService().fullName(name); return mapperService().fieldType(name);
} }
@Override @Override

View File

@ -93,7 +93,7 @@ public final class DocValueFieldsFetchSubPhase implements FetchSubPhase {
for (FieldAndFormat fieldAndFormat : context.docValueFieldsContext().fields()) { for (FieldAndFormat fieldAndFormat : context.docValueFieldsContext().fields()) {
String field = fieldAndFormat.field; String field = fieldAndFormat.field;
MappedFieldType fieldType = context.mapperService().fullName(field); MappedFieldType fieldType = context.mapperService().fieldType(field);
if (fieldType != null) { if (fieldType != null) {
final IndexFieldData<?> indexFieldData = context.getForField(fieldType); final IndexFieldData<?> indexFieldData = context.getForField(fieldType);
final boolean isNanosecond; final boolean isNanosecond;

View File

@ -74,7 +74,7 @@ public class HighlightPhase implements FetchSubPhase {
boolean fieldNameContainsWildcards = field.field().contains("*"); boolean fieldNameContainsWildcards = field.field().contains("*");
for (String fieldName : fieldNamesToHighlight) { for (String fieldName : fieldNamesToHighlight) {
MappedFieldType fieldType = context.getMapperService().fullName(fieldName); MappedFieldType fieldType = context.getMapperService().fieldType(fieldName);
if (fieldType == null) { if (fieldType == null) {
continue; continue;
} }

View File

@ -88,7 +88,7 @@ public class LeafDocLookup implements Map<String, ScriptDocValues<?>> {
String fieldName = key.toString(); String fieldName = key.toString();
ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName); ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) { if (scriptValues == null) {
final MappedFieldType fieldType = mapperService.fullName(fieldName); final MappedFieldType fieldType = mapperService.fieldType(fieldName);
if (fieldType == null) { if (fieldType == null) {
throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " + throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " +
Arrays.toString(types)); Arrays.toString(types));
@ -117,7 +117,7 @@ public class LeafDocLookup implements Map<String, ScriptDocValues<?>> {
String fieldName = key.toString(); String fieldName = key.toString();
ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName); ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName);
if (scriptValues == null) { if (scriptValues == null) {
MappedFieldType fieldType = mapperService.fullName(fieldName); MappedFieldType fieldType = mapperService.fieldType(fieldName);
if (fieldType == null) { if (fieldType == null) {
return false; return false;
} }

View File

@ -134,7 +134,7 @@ public class LeafFieldsLookup implements Map {
private FieldLookup loadFieldData(String name) { private FieldLookup loadFieldData(String name) {
FieldLookup data = cachedFieldData.get(name); FieldLookup data = cachedFieldData.get(name);
if (data == null) { if (data == null) {
MappedFieldType fieldType = mapperService.fullName(name); MappedFieldType fieldType = mapperService.fieldType(name);
if (fieldType == null) { if (fieldType == null) {
throw new IllegalArgumentException("No field found for [" + name + "] in mapping with types " + Arrays.toString(types)); throw new IllegalArgumentException("No field found for [" + name + "] in mapping with types " + Arrays.toString(types));
} }

View File

@ -421,7 +421,7 @@ public class QueryPhase implements SearchPhase {
String fieldName = sortField.getField(); String fieldName = sortField.getField();
if (fieldName == null) return null; // happens when _score or _doc is the 1st sort field if (fieldName == null) return null; // happens when _score or _doc is the 1st sort field
if (searchContext.mapperService() == null) return null; // mapperService can be null in tests if (searchContext.mapperService() == null) return null; // mapperService can be null in tests
final MappedFieldType fieldType = searchContext.mapperService().fullName(fieldName); final MappedFieldType fieldType = searchContext.mapperService().fieldType(fieldName);
if (fieldType == null) return null; // for unmapped fields, default behaviour depending on "unmapped_type" flag if (fieldType == null) return null; // for unmapped fields, default behaviour depending on "unmapped_type" flag
if ((fieldType.typeName().equals("long") == false) && (fieldType instanceof DateFieldType == false)) return null; if ((fieldType.typeName().equals("long") == false) && (fieldType instanceof DateFieldType == false)) return null;
if (fieldType.indexOptions() == IndexOptions.NONE) return null; //TODO: change to pointDataDimensionCount() when implemented if (fieldType.indexOptions() == IndexOptions.NONE) return null; //TODO: change to pointDataDimensionCount() when implemented
@ -436,7 +436,7 @@ public class QueryPhase implements SearchPhase {
if (SortField.FIELD_DOC.equals(sField) == false) return null; if (SortField.FIELD_DOC.equals(sField) == false) return null;
} else { } else {
//TODO: find out how to cover _script sort that don't use _score //TODO: find out how to cover _script sort that don't use _score
if (searchContext.mapperService().fullName(sFieldName) == null) return null; // could be _script sort that uses _score if (searchContext.mapperService().fieldType(sFieldName) == null) return null; // could be _script sort that uses _score
} }
} }

View File

@ -302,7 +302,7 @@ public abstract class SuggestionBuilder<T extends SuggestionBuilder<T>> implemen
Objects.requireNonNull(field, "field must not be null"); Objects.requireNonNull(field, "field must not be null");
MappedFieldType fieldType = mapperService.fullName(field); MappedFieldType fieldType = mapperService.fieldType(field);
if (fieldType == null) { if (fieldType == null) {
throw new IllegalArgumentException("no mapping found for field [" + field + "]"); throw new IllegalArgumentException("no mapping found for field [" + field + "]");
} else if (analyzer == null) { } else if (analyzer == null) {

View File

@ -297,7 +297,7 @@ public class CompletionSuggestionBuilder extends SuggestionBuilder<CompletionSug
if (shardSize != null) { if (shardSize != null) {
suggestionContext.setShardSize(shardSize); suggestionContext.setShardSize(shardSize);
} }
MappedFieldType mappedFieldType = mapperService.fullName(suggestionContext.getField()); MappedFieldType mappedFieldType = mapperService.fieldType(suggestionContext.getField());
if (mappedFieldType == null || mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType == false) { if (mappedFieldType == null || mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType == false) {
throw new IllegalArgumentException("Field [" + suggestionContext.getField() + "] is not a completion suggest field"); throw new IllegalArgumentException("Field [" + suggestionContext.getField() + "] is not a completion suggest field");
} }

View File

@ -146,7 +146,7 @@ public class GeoContextMapping extends ContextMapping<GeoQueryContext> {
@Override @Override
public Set<String> parseContext(ParseContext parseContext, XContentParser parser) throws IOException, ElasticsearchParseException { public Set<String> parseContext(ParseContext parseContext, XContentParser parser) throws IOException, ElasticsearchParseException {
if (fieldName != null) { if (fieldName != null) {
MappedFieldType fieldType = parseContext.mapperService().fullName(fieldName); MappedFieldType fieldType = parseContext.mapperService().fieldType(fieldName);
if (!(fieldType instanceof GeoPointFieldMapper.GeoPointFieldType)) { if (!(fieldType instanceof GeoPointFieldMapper.GeoPointFieldType)) {
throw new ElasticsearchParseException("referenced field must be mapped to geo_point"); throw new ElasticsearchParseException("referenced field must be mapped to geo_point");
} }

View File

@ -94,7 +94,7 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
.field("analyzer", analyzerName).endObject().endObject().endObject().endObject(); .field("analyzer", analyzerName).endObject().endObject().endObject().endObject();
MapperService mapperService = createIndex("test", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("test", indexSettings, "type", mapping).mapperService();
MappedFieldType fieldType = mapperService.fullName("field"); MappedFieldType fieldType = mapperService.fieldType("field");
assertThat(fieldType.searchAnalyzer(), instanceOf(NamedAnalyzer.class)); assertThat(fieldType.searchAnalyzer(), instanceOf(NamedAnalyzer.class));
NamedAnalyzer fieldMapperNamedAnalyzer = fieldType.searchAnalyzer(); NamedAnalyzer fieldMapperNamedAnalyzer = fieldType.searchAnalyzer();

View File

@ -60,7 +60,7 @@ public class BinaryFieldMapperTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type", mapping).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type", mapping).mapperService();
MappedFieldType fieldType = mapperService.fullName("field"); MappedFieldType fieldType = mapperService.fieldType("field");
assertThat(fieldType, instanceOf(BinaryFieldMapper.BinaryFieldType.class)); assertThat(fieldType, instanceOf(BinaryFieldMapper.BinaryFieldType.class));
assertThat(fieldType.stored(), equalTo(false)); assertThat(fieldType.stored(), equalTo(false));
@ -97,7 +97,7 @@ public class BinaryFieldMapperTests extends ESSingleNodeTestCase {
BytesRef indexedValue = doc.rootDoc().getBinaryValue("field"); BytesRef indexedValue = doc.rootDoc().getBinaryValue("field");
assertEquals(new BytesRef(value), indexedValue); assertEquals(new BytesRef(value), indexedValue);
MappedFieldType fieldType = mapperService.fullName("field"); MappedFieldType fieldType = mapperService.fieldType("field");
Object originalValue = fieldType.valueForDisplay(indexedValue); Object originalValue = fieldType.valueForDisplay(indexedValue);
assertEquals(new BytesArray(value), originalValue); assertEquals(new BytesArray(value), originalValue);
} }

View File

@ -370,8 +370,8 @@ public class DateFieldMapperTests extends ESSingleNodeTestCase {
indexService.mapperService().merge("movie", new CompressedXContent(initMapping), indexService.mapperService().merge("movie", new CompressedXContent(initMapping),
MapperService.MergeReason.MAPPING_UPDATE); MapperService.MergeReason.MAPPING_UPDATE);
assertThat(indexService.mapperService().fullName("release_date"), notNullValue()); assertThat(indexService.mapperService().fieldType("release_date"), notNullValue());
assertFalse(indexService.mapperService().fullName("release_date").stored()); assertFalse(indexService.mapperService().fieldType("release_date").stored());
String updateFormatMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("movie") String updateFormatMapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("movie")
.startObject("properties") .startObject("properties")

View File

@ -116,7 +116,7 @@ public class DocumentMapperTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type", mapping1).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type", mapping1).mapperService();
assertThat(mapperService.fullName("field").searchAnalyzer().name(), equalTo("whitespace")); assertThat(mapperService.fieldType("field").searchAnalyzer().name(), equalTo("whitespace"));
String mapping2 = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type") String mapping2 = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field") .startObject("properties").startObject("field")
@ -127,7 +127,7 @@ public class DocumentMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()); .endObject().endObject());
mapperService.merge("type", new CompressedXContent(mapping2), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("type", new CompressedXContent(mapping2), MapperService.MergeReason.MAPPING_UPDATE);
assertThat(mapperService.fullName("field").searchAnalyzer().name(), equalTo("keyword")); assertThat(mapperService.fieldType("field").searchAnalyzer().name(), equalTo("keyword"));
} }
public void testChangeSearchAnalyzerToDefault() throws Exception { public void testChangeSearchAnalyzerToDefault() throws Exception {
@ -140,7 +140,7 @@ public class DocumentMapperTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type", mapping1).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type", mapping1).mapperService();
assertThat(mapperService.fullName("field").searchAnalyzer().name(), equalTo("whitespace")); assertThat(mapperService.fieldType("field").searchAnalyzer().name(), equalTo("whitespace"));
String mapping2 = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type") String mapping2 = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field") .startObject("properties").startObject("field")
@ -150,7 +150,7 @@ public class DocumentMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()); .endObject().endObject());
mapperService.merge("type", new CompressedXContent(mapping2), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("type", new CompressedXContent(mapping2), MapperService.MergeReason.MAPPING_UPDATE);
assertThat(mapperService.fullName("field").searchAnalyzer().name(), equalTo("standard")); assertThat(mapperService.fieldType("field").searchAnalyzer().name(), equalTo("standard"));
} }
public void testConcurrentMergeTest() throws Throwable { public void testConcurrentMergeTest() throws Throwable {

View File

@ -70,25 +70,25 @@ public class DoubleIndexingDocTests extends ESSingleNodeTestCase {
IndexReader reader = DirectoryReader.open(writer); IndexReader reader = DirectoryReader.open(writer);
IndexSearcher searcher = new IndexSearcher(reader); IndexSearcher searcher = new IndexSearcher(reader);
TopDocs topDocs = searcher.search(mapperService.fullName("field1").termQuery("value1", context), 10); TopDocs topDocs = searcher.search(mapperService.fieldType("field1").termQuery("value1", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
topDocs = searcher.search(mapperService.fullName("field2").termQuery("1", context), 10); topDocs = searcher.search(mapperService.fieldType("field2").termQuery("1", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
topDocs = searcher.search(mapperService.fullName("field3").termQuery("1.1", context), 10); topDocs = searcher.search(mapperService.fieldType("field3").termQuery("1.1", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
topDocs = searcher.search(mapperService.fullName("field4").termQuery("2010-01-01", context), 10); topDocs = searcher.search(mapperService.fieldType("field4").termQuery("2010-01-01", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
topDocs = searcher.search(mapperService.fullName("field5").termQuery("1", context), 10); topDocs = searcher.search(mapperService.fieldType("field5").termQuery("1", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
topDocs = searcher.search(mapperService.fullName("field5").termQuery("2", context), 10); topDocs = searcher.search(mapperService.fieldType("field5").termQuery("2", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
topDocs = searcher.search(mapperService.fullName("field5").termQuery("3", context), 10); topDocs = searcher.search(mapperService.fieldType("field5").termQuery("3", context), 10);
assertThat(topDocs.totalHits.value, equalTo(2L)); assertThat(topDocs.totalHits.value, equalTo(2L));
writer.close(); writer.close();
reader.close(); reader.close();

View File

@ -193,7 +193,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
public void testDynamicMappingOnEmptyString() throws Exception { public void testDynamicMappingOnEmptyString() throws Exception {
IndexService service = createIndex("test"); IndexService service = createIndex("test");
client().prepareIndex("test", "type").setSource("empty_field", "").get(); client().prepareIndex("test", "type").setSource("empty_field", "").get();
MappedFieldType fieldType = service.mapperService().fullName("empty_field"); MappedFieldType fieldType = service.mapperService().fieldType("empty_field");
assertNotNull(fieldType); assertNotNull(fieldType);
} }
@ -742,7 +742,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
IndexService index = createIndex("test", Settings.EMPTY, "type", mapping); IndexService index = createIndex("test", Settings.EMPTY, "type", mapping);
client().prepareIndex("test", "type", "1").setSource("foo", "abc").get(); client().prepareIndex("test", "type", "1").setSource("foo", "abc").get();
assertThat(index.mapperService().fullName("foo"), instanceOf(KeywordFieldMapper.KeywordFieldType.class)); assertThat(index.mapperService().fieldType("foo"), instanceOf(KeywordFieldMapper.KeywordFieldType.class));
} }
public void testMappingVersionAfterDynamicMappingUpdate() { public void testMappingVersionAfterDynamicMappingUpdate() {

View File

@ -55,11 +55,11 @@ public class DynamicTemplatesTests extends ESSingleNodeTestCase {
client().admin().indices().preparePutMapping("test").setType("person") client().admin().indices().preparePutMapping("test").setType("person")
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get(); .setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
assertThat(mapperService.fullName("s"), notNullValue()); assertThat(mapperService.fieldType("s"), notNullValue());
assertEquals(IndexOptions.NONE, mapperService.fullName("s").indexOptions()); assertEquals(IndexOptions.NONE, mapperService.fieldType("s").indexOptions());
assertThat(mapperService.fullName("l"), notNullValue()); assertThat(mapperService.fieldType("l"), notNullValue());
assertNotSame(IndexOptions.NONE, mapperService.fullName("l").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("l").indexOptions());
} }
public void testSimple() throws Exception { public void testSimple() throws Exception {

View File

@ -110,7 +110,7 @@ public class FieldAliasMapperTests extends ESSingleNodeTestCase {
.endObject()); .endObject());
mapperService.merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE); mapperService.merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE);
MappedFieldType firstFieldType = mapperService.fullName("alias-field"); MappedFieldType firstFieldType = mapperService.fieldType("alias-field");
assertEquals("first-field", firstFieldType.name()); assertEquals("first-field", firstFieldType.name());
assertTrue(firstFieldType instanceof KeywordFieldMapper.KeywordFieldType); assertTrue(firstFieldType instanceof KeywordFieldMapper.KeywordFieldType);
@ -129,7 +129,7 @@ public class FieldAliasMapperTests extends ESSingleNodeTestCase {
.endObject()); .endObject());
mapperService.merge("type", new CompressedXContent(newMapping), MergeReason.MAPPING_UPDATE); mapperService.merge("type", new CompressedXContent(newMapping), MergeReason.MAPPING_UPDATE);
MappedFieldType secondFieldType = mapperService.fullName("alias-field"); MappedFieldType secondFieldType = mapperService.fieldType("alias-field");
assertEquals("second-field", secondFieldType.name()); assertEquals("second-field", secondFieldType.name());
assertTrue(secondFieldType instanceof TextFieldMapper.TextFieldType); assertTrue(secondFieldType instanceof TextFieldMapper.TextFieldType);
} }

View File

@ -62,8 +62,8 @@ public class FieldNamesFieldTypeTests extends FieldTypeTestCase {
IndexSettings indexSettings = new IndexSettings( IndexSettings indexSettings = new IndexSettings(
new IndexMetaData.Builder("foo").settings(settings).numberOfShards(1).numberOfReplicas(0).build(), settings); new IndexMetaData.Builder("foo").settings(settings).numberOfShards(1).numberOfReplicas(0).build(), settings);
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName("_field_names")).thenReturn(fieldNamesFieldType); when(mapperService.fieldType("_field_names")).thenReturn(fieldNamesFieldType);
when(mapperService.fullName("field_name")).thenReturn(fieldType); when(mapperService.fieldType("field_name")).thenReturn(fieldType);
when(mapperService.simpleMatchToFullName("field_name")).thenReturn(Collections.singleton("field_name")); when(mapperService.simpleMatchToFullName("field_name")).thenReturn(Collections.singleton("field_name"));
QueryShardContext queryShardContext = new QueryShardContext(0, QueryShardContext queryShardContext = new QueryShardContext(0,

View File

@ -50,7 +50,7 @@ public class GenericStoreDynamicTemplateTests extends ESSingleNodeTestCase {
assertThat(f.stringValue(), equalTo("some name")); assertThat(f.stringValue(), equalTo("some name"));
assertThat(f.fieldType().stored(), equalTo(true)); assertThat(f.fieldType().stored(), equalTo(true));
MappedFieldType fieldType = mapperService.fullName("name"); MappedFieldType fieldType = mapperService.fieldType("name");
assertThat(fieldType.stored(), equalTo(true)); assertThat(fieldType.stored(), equalTo(true));
boolean stored = false; boolean stored = false;
@ -59,7 +59,7 @@ public class GenericStoreDynamicTemplateTests extends ESSingleNodeTestCase {
} }
assertTrue(stored); assertTrue(stored);
fieldType = mapperService.fullName("age"); fieldType = mapperService.fieldType("age");
assertThat(fieldType.stored(), equalTo(true)); assertThat(fieldType.stored(), equalTo(true));
} }
} }

View File

@ -80,7 +80,7 @@ public class IdFieldMapperTests extends ESSingleNodeTestCase {
IndexService service = createIndex("test", Settings.EMPTY); IndexService service = createIndex("test", Settings.EMPTY);
MapperService mapperService = service.mapperService(); MapperService mapperService = service.mapperService();
mapperService.merge("type", new CompressedXContent("{\"type\":{}}"), MergeReason.MAPPING_UPDATE); mapperService.merge("type", new CompressedXContent("{\"type\":{}}"), MergeReason.MAPPING_UPDATE);
IdFieldMapper.IdFieldType ft = (IdFieldMapper.IdFieldType) service.mapperService().fullName("_id"); IdFieldMapper.IdFieldType ft = (IdFieldMapper.IdFieldType) service.mapperService().fieldType("_id");
ft.fielddataBuilder("test").build(mapperService.getIndexSettings(), ft.fielddataBuilder("test").build(mapperService.getIndexSettings(),
ft, null, null, mapperService); ft, null, null, mapperService);

View File

@ -40,8 +40,8 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), nullValue()); assertThat(mapperService.fieldType("name.indexed"), nullValue());
BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject()); BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject());
Document doc = mapperService.documentMapper().parse( Document doc = mapperService.documentMapper().parse(
@ -54,12 +54,12 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json"); mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping2.json");
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed2"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed2"), nullValue());
assertThat(mapperService.fullName("name.not_indexed3"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue());
doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); doc = mapperService.documentMapper().parse(new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc();
f = doc.getField("name"); f = doc.getField("name");
@ -70,22 +70,22 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json"); mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping3.json");
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed2"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed2"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed3"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue());
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json"); mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/test-mapping4.json");
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed2"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed2"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed3"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), notNullValue());
} }
public void testUpgradeFromMultiFieldTypeToMultiFields() throws Exception { public void testUpgradeFromMultiFieldTypeToMultiFields() throws Exception {
@ -94,8 +94,8 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), nullValue()); assertThat(mapperService.fieldType("name.indexed"), nullValue());
BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject()); BytesReference json = BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("name", "some name").endObject());
Document doc = mapperService.documentMapper().parse( Document doc = mapperService.documentMapper().parse(
@ -109,12 +109,12 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/upgrade1.json"); mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/upgrade1.json");
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed2"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed2"), nullValue());
assertThat(mapperService.fullName("name.not_indexed3"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue());
doc = mapperService.documentMapper().parse( doc = mapperService.documentMapper().parse(
new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc(); new SourceToParse("test", "person", "1", json, XContentType.JSON)).rootDoc();
@ -126,12 +126,12 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/upgrade2.json"); mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/upgrade2.json");
mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("person", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed2"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed2"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed3"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue());
mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/upgrade3.json"); mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/merge/upgrade3.json");
@ -144,10 +144,10 @@ public class JavaMultiFieldMergeTests extends ESSingleNodeTestCase {
} }
// There are conflicts, so the `name.not_indexed3` has not been added // There are conflicts, so the `name.not_indexed3` has not been added
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed2"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed2"), notNullValue());
assertThat(mapperService.fullName("name.not_indexed3"), nullValue()); assertThat(mapperService.fieldType("name.not_indexed3"), nullValue());
} }
} }

View File

@ -510,12 +510,12 @@ public class KeywordFieldMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()); .endObject().endObject());
indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE); indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE);
MappedFieldType fieldType = indexService.mapperService().fullName("field"); MappedFieldType fieldType = indexService.mapperService().fieldType("field");
assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class)); assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class));
KeywordFieldMapper.KeywordFieldType ft = (KeywordFieldMapper.KeywordFieldType) fieldType; KeywordFieldMapper.KeywordFieldType ft = (KeywordFieldMapper.KeywordFieldType) fieldType;
assertTokenStreamContents(ft.searchAnalyzer().analyzer().tokenStream("", "Hello World"), new String[] {"Hello World"}); assertTokenStreamContents(ft.searchAnalyzer().analyzer().tokenStream("", "Hello World"), new String[] {"Hello World"});
fieldType = indexService.mapperService().fullName("field_with_normalizer"); fieldType = indexService.mapperService().fieldType("field_with_normalizer");
assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class)); assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class));
ft = (KeywordFieldMapper.KeywordFieldType) fieldType; ft = (KeywordFieldMapper.KeywordFieldType) fieldType;
assertThat(ft.searchAnalyzer().name(), equalTo("my_lowercase")); assertThat(ft.searchAnalyzer().name(), equalTo("my_lowercase"));
@ -537,12 +537,12 @@ public class KeywordFieldMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()); .endObject().endObject());
indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE); indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE);
fieldType = indexService.mapperService().fullName("field"); fieldType = indexService.mapperService().fieldType("field");
assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class)); assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class));
ft = (KeywordFieldMapper.KeywordFieldType) fieldType; ft = (KeywordFieldMapper.KeywordFieldType) fieldType;
assertTokenStreamContents(ft.searchAnalyzer().analyzer().tokenStream("", "Hello World"), new String[] {"Hello", "World"}); assertTokenStreamContents(ft.searchAnalyzer().analyzer().tokenStream("", "Hello World"), new String[] {"Hello", "World"});
fieldType = indexService.mapperService().fullName("field_with_normalizer"); fieldType = indexService.mapperService().fieldType("field_with_normalizer");
assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class)); assertThat(fieldType, instanceOf(KeywordFieldMapper.KeywordFieldType.class));
ft = (KeywordFieldMapper.KeywordFieldType) fieldType; ft = (KeywordFieldMapper.KeywordFieldType) fieldType;
assertThat(ft.searchAnalyzer().name(), equalTo("my_lowercase")); assertThat(ft.searchAnalyzer().name(), equalTo("my_lowercase"));

View File

@ -133,9 +133,9 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
final MapperService mapperService = createIndex("test1").mapperService(); final MapperService mapperService = createIndex("test1").mapperService();
final CompressedXContent mapping = createMappingSpecifyingNumberOfFields(1); final CompressedXContent mapping = createMappingSpecifyingNumberOfFields(1);
mapperService.merge("type", mapping, MergeReason.MAPPING_UPDATE_PREFLIGHT); mapperService.merge("type", mapping, MergeReason.MAPPING_UPDATE_PREFLIGHT);
assertThat("field was not created by preflight check", mapperService.fullName("field0"), nullValue()); assertThat("field was not created by preflight check", mapperService.fieldType("field0"), nullValue());
mapperService.merge("type", mapping, MergeReason.MAPPING_UPDATE); mapperService.merge("type", mapping, MergeReason.MAPPING_UPDATE);
assertThat("field was not created by mapping update", mapperService.fullName("field0"), notNullValue()); assertThat("field was not created by mapping update", mapperService.fieldType("field0"), notNullValue());
} }
/** /**
@ -471,8 +471,8 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
assertSame(current.getDefaultSearchQuoteAnalyzer(), updatedAnalyzers.getDefaultSearchQuoteAnalyzer()); assertSame(current.getDefaultSearchQuoteAnalyzer(), updatedAnalyzers.getDefaultSearchQuoteAnalyzer());
assertFalse(assertSameContainedFilters(originalTokenFilters, current.get("reloadableAnalyzer"))); assertFalse(assertSameContainedFilters(originalTokenFilters, current.get("reloadableAnalyzer")));
assertFalse(assertSameContainedFilters(originalTokenFilters, mapperService.fullName("field").searchAnalyzer())); assertFalse(assertSameContainedFilters(originalTokenFilters, mapperService.fieldType("field").searchAnalyzer()));
assertFalse(assertSameContainedFilters(originalTokenFilters, mapperService.fullName("otherField").searchQuoteAnalyzer())); assertFalse(assertSameContainedFilters(originalTokenFilters, mapperService.fieldType("otherField").searchQuoteAnalyzer()));
} }
private boolean assertSameContainedFilters(TokenFilterFactory[] originalTokenFilter, NamedAnalyzer updatedAnalyzer) { private boolean assertSameContainedFilters(TokenFilterFactory[] originalTokenFilter, NamedAnalyzer updatedAnalyzer) {

View File

@ -91,37 +91,37 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
assertThat(f.name(), equalTo("object1.multi1.string")); assertThat(f.name(), equalTo("object1.multi1.string"));
assertThat(f.binaryValue(), equalTo(new BytesRef("2010-01-01"))); assertThat(f.binaryValue(), equalTo(new BytesRef("2010-01-01")));
assertThat(mapperService.fullName("name"), notNullValue()); assertThat(mapperService.fieldType("name"), notNullValue());
assertThat(mapperService.fullName("name"), instanceOf(TextFieldType.class)); assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertNotSame(IndexOptions.NONE, mapperService.fullName("name").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name").indexOptions());
assertThat(mapperService.fullName("name").stored(), equalTo(true)); assertThat(mapperService.fieldType("name").stored(), equalTo(true));
assertThat(mapperService.fullName("name").tokenized(), equalTo(true)); assertThat(mapperService.fieldType("name").tokenized(), equalTo(true));
assertThat(mapperService.fullName("name.indexed"), notNullValue()); assertThat(mapperService.fieldType("name.indexed"), notNullValue());
assertThat(mapperService.fullName("name"), instanceOf(TextFieldType.class)); assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertNotSame(IndexOptions.NONE, mapperService.fullName("name.indexed").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name.indexed").indexOptions());
assertThat(mapperService.fullName("name.indexed").stored(), equalTo(false)); assertThat(mapperService.fieldType("name.indexed").stored(), equalTo(false));
assertThat(mapperService.fullName("name.indexed").tokenized(), equalTo(true)); assertThat(mapperService.fieldType("name.indexed").tokenized(), equalTo(true));
assertThat(mapperService.fullName("name.not_indexed"), notNullValue()); assertThat(mapperService.fieldType("name.not_indexed"), notNullValue());
assertThat(mapperService.fullName("name"), instanceOf(TextFieldType.class)); assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertEquals(IndexOptions.NONE, mapperService.fullName("name.not_indexed").indexOptions()); assertEquals(IndexOptions.NONE, mapperService.fieldType("name.not_indexed").indexOptions());
assertThat(mapperService.fullName("name.not_indexed").stored(), equalTo(true)); assertThat(mapperService.fieldType("name.not_indexed").stored(), equalTo(true));
assertThat(mapperService.fullName("name.not_indexed").tokenized(), equalTo(true)); assertThat(mapperService.fieldType("name.not_indexed").tokenized(), equalTo(true));
assertThat(mapperService.fullName("name.test1"), notNullValue()); assertThat(mapperService.fieldType("name.test1"), notNullValue());
assertThat(mapperService.fullName("name"), instanceOf(TextFieldType.class)); assertThat(mapperService.fieldType("name"), instanceOf(TextFieldType.class));
assertNotSame(IndexOptions.NONE, mapperService.fullName("name.test1").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("name.test1").indexOptions());
assertThat(mapperService.fullName("name.test1").stored(), equalTo(true)); assertThat(mapperService.fieldType("name.test1").stored(), equalTo(true));
assertThat(mapperService.fullName("name.test1").tokenized(), equalTo(true)); assertThat(mapperService.fieldType("name.test1").tokenized(), equalTo(true));
assertThat(mapperService.fullName("name.test1").eagerGlobalOrdinals(), equalTo(true)); assertThat(mapperService.fieldType("name.test1").eagerGlobalOrdinals(), equalTo(true));
assertThat(mapperService.fullName("object1.multi1"), notNullValue()); assertThat(mapperService.fieldType("object1.multi1"), notNullValue());
assertThat(mapperService.fullName("object1.multi1"), instanceOf(DateFieldMapper.DateFieldType.class)); assertThat(mapperService.fieldType("object1.multi1"), instanceOf(DateFieldMapper.DateFieldType.class));
assertThat(mapperService.fullName("object1.multi1.string"), notNullValue()); assertThat(mapperService.fieldType("object1.multi1.string"), notNullValue());
assertThat(mapperService.fullName("object1.multi1.string"), instanceOf(KeywordFieldMapper.KeywordFieldType.class)); assertThat(mapperService.fieldType("object1.multi1.string"), instanceOf(KeywordFieldMapper.KeywordFieldType.class));
assertNotSame(IndexOptions.NONE, mapperService.fullName("object1.multi1.string").indexOptions()); assertNotSame(IndexOptions.NONE, mapperService.fieldType("object1.multi1.string").indexOptions());
assertThat(mapperService.fullName("object1.multi1.string").tokenized(), equalTo(false)); assertThat(mapperService.fieldType("object1.multi1.string").tokenized(), equalTo(false));
} }
public void testBuildThenParse() throws Exception { public void testBuildThenParse() throws Exception {

View File

@ -50,26 +50,26 @@ public class PathMatchDynamicTemplateTests extends ESSingleNodeTestCase {
assertThat(f.stringValue(), equalTo("top_level")); assertThat(f.stringValue(), equalTo("top_level"));
assertThat(f.fieldType().stored(), equalTo(false)); assertThat(f.fieldType().stored(), equalTo(false));
MappedFieldType fieldType = mapperService.fullName("name"); MappedFieldType fieldType = mapperService.fieldType("name");
assertThat(fieldType.stored(), equalTo(false)); assertThat(fieldType.stored(), equalTo(false));
f = doc.getField("obj1.name"); f = doc.getField("obj1.name");
assertThat(f.name(), equalTo("obj1.name")); assertThat(f.name(), equalTo("obj1.name"));
assertThat(f.fieldType().stored(), equalTo(true)); assertThat(f.fieldType().stored(), equalTo(true));
fieldType = mapperService.fullName("obj1.name"); fieldType = mapperService.fieldType("obj1.name");
assertThat(fieldType.stored(), equalTo(true)); assertThat(fieldType.stored(), equalTo(true));
f = doc.getField("obj1.obj2.name"); f = doc.getField("obj1.obj2.name");
assertThat(f.name(), equalTo("obj1.obj2.name")); assertThat(f.name(), equalTo("obj1.obj2.name"));
assertThat(f.fieldType().stored(), equalTo(false)); assertThat(f.fieldType().stored(), equalTo(false));
fieldType = mapperService.fullName("obj1.obj2.name"); fieldType = mapperService.fieldType("obj1.obj2.name");
assertThat(fieldType.stored(), equalTo(false)); assertThat(fieldType.stored(), equalTo(false));
// verify more complex path_match expressions // verify more complex path_match expressions
fieldType = mapperService.fullName("obj3.obj4.prop1"); fieldType = mapperService.fieldType("obj3.obj4.prop1");
assertNotNull(fieldType); assertNotNull(fieldType);
} }
} }

View File

@ -748,7 +748,7 @@ public class TextFieldMapperTests extends ESSingleNodeTestCase {
.endObject()); .endObject());
indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE); indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE);
MappedFieldType textField = indexService.mapperService().fullName("object.field"); MappedFieldType textField = indexService.mapperService().fieldType("object.field");
assertNotNull(textField); assertNotNull(textField);
assertThat(textField, instanceOf(TextFieldType.class)); assertThat(textField, instanceOf(TextFieldType.class));
MappedFieldType prefix = ((TextFieldType) textField).getPrefixFieldType(); MappedFieldType prefix = ((TextFieldType) textField).getPrefixFieldType();
@ -774,7 +774,7 @@ public class TextFieldMapperTests extends ESSingleNodeTestCase {
.endObject()); .endObject());
indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE); indexService.mapperService().merge("type", new CompressedXContent(mapping), MergeReason.MAPPING_UPDATE);
MappedFieldType textField = indexService.mapperService().fullName("body.with_prefix"); MappedFieldType textField = indexService.mapperService().fieldType("body.with_prefix");
assertNotNull(textField); assertNotNull(textField);
assertThat(textField, instanceOf(TextFieldType.class)); assertThat(textField, instanceOf(TextFieldType.class));
MappedFieldType prefix = ((TextFieldType) textField).getPrefixFieldType(); MappedFieldType prefix = ((TextFieldType) textField).getPrefixFieldType();

View File

@ -67,7 +67,7 @@ public class TypeFieldMapperTests extends ESSingleNodeTestCase {
DirectoryReader r = DirectoryReader.open(w); DirectoryReader r = DirectoryReader.open(w);
w.close(); w.close();
MappedFieldType ft = mapperService.fullName(TypeFieldMapper.NAME); MappedFieldType ft = mapperService.fieldType(TypeFieldMapper.NAME);
IndexOrdinalsFieldData fd = (IndexOrdinalsFieldData) ft.fielddataBuilder("test").build(mapperService.getIndexSettings(), IndexOrdinalsFieldData fd = (IndexOrdinalsFieldData) ft.fielddataBuilder("test").build(mapperService.getIndexSettings(),
ft, new IndexFieldDataCache.None(), new NoneCircuitBreakerService(), mapperService); ft, new IndexFieldDataCache.None(), new NoneCircuitBreakerService(), mapperService);
AtomicOrdinalsFieldData afd = fd.load(r.leaves().get(0)); AtomicOrdinalsFieldData afd = fd.load(r.leaves().get(0));

View File

@ -86,7 +86,7 @@ public class DistanceFeatureQueryBuilderTests extends AbstractQueryTestCase<Dist
expectedQuery = LatLonPoint.newDistanceFeatureQuery(fieldName, boost, originGeoPoint.lat(), originGeoPoint.lon(), pivotDouble); expectedQuery = LatLonPoint.newDistanceFeatureQuery(fieldName, boost, originGeoPoint.lat(), originGeoPoint.lon(), pivotDouble);
} else { // if (fieldName.equals(DATE_FIELD_NAME)) } else { // if (fieldName.equals(DATE_FIELD_NAME))
MapperService mapperService = context.getMapperService(); MapperService mapperService = context.getMapperService();
DateFieldType fieldType = (DateFieldType) mapperService.fullName(fieldName); DateFieldType fieldType = (DateFieldType) mapperService.fieldType(fieldName);
long originLong = fieldType.parseToLong(origin, true, null, null, context::nowInMillis); long originLong = fieldType.parseToLong(origin, true, null, null, context::nowInMillis);
TimeValue pivotVal = TimeValue.parseTimeValue(pivot, DistanceFeatureQueryBuilder.class.getSimpleName() + ".pivot"); TimeValue pivotVal = TimeValue.parseTimeValue(pivot, DistanceFeatureQueryBuilder.class.getSimpleName() + ".pivot");
long pivotLong; long pivotLong;

View File

@ -63,7 +63,7 @@ public class ExistsQueryBuilderTests extends AbstractQueryTestCase<ExistsQueryBu
String fieldPattern = queryBuilder.fieldName(); String fieldPattern = queryBuilder.fieldName();
Collection<String> fields = context.simpleMatchToIndexNames(fieldPattern); Collection<String> fields = context.simpleMatchToIndexNames(fieldPattern);
Collection<String> mappedFields = fields.stream().filter((field) -> context.getObjectMapper(field) != null Collection<String> mappedFields = fields.stream().filter((field) -> context.getObjectMapper(field) != null
|| context.getMapperService().fullName(field) != null).collect(Collectors.toList()); || context.getMapperService().fieldType(field) != null).collect(Collectors.toList());
if (context.getIndexSettings().getIndexVersionCreated().before(Version.V_6_1_0)) { if (context.getIndexSettings().getIndexVersionCreated().before(Version.V_6_1_0)) {
if (fields.size() == 1) { if (fields.size() == 1) {
assertThat(query, instanceOf(ConstantScoreQuery.class)); assertThat(query, instanceOf(ConstantScoreQuery.class));
@ -102,11 +102,11 @@ public class ExistsQueryBuilderTests extends AbstractQueryTestCase<ExistsQueryBu
BooleanClause booleanClause = booleanQuery.clauses().get(i); BooleanClause booleanClause = booleanQuery.clauses().get(i);
assertThat(booleanClause.getOccur(), equalTo(BooleanClause.Occur.SHOULD)); assertThat(booleanClause.getOccur(), equalTo(BooleanClause.Occur.SHOULD));
} }
} else if (context.getMapperService().fullName(field).hasDocValues()) { } else if (context.getMapperService().fieldType(field).hasDocValues()) {
assertThat(constantScoreQuery.getQuery(), instanceOf(DocValuesFieldExistsQuery.class)); assertThat(constantScoreQuery.getQuery(), instanceOf(DocValuesFieldExistsQuery.class));
DocValuesFieldExistsQuery dvExistsQuery = (DocValuesFieldExistsQuery) constantScoreQuery.getQuery(); DocValuesFieldExistsQuery dvExistsQuery = (DocValuesFieldExistsQuery) constantScoreQuery.getQuery();
assertEquals(field, dvExistsQuery.getField()); assertEquals(field, dvExistsQuery.getField());
} else if (context.getMapperService().fullName(field).omitNorms() == false) { } else if (context.getMapperService().fieldType(field).omitNorms() == false) {
assertThat(constantScoreQuery.getQuery(), instanceOf(NormsFieldExistsQuery.class)); assertThat(constantScoreQuery.getQuery(), instanceOf(NormsFieldExistsQuery.class));
NormsFieldExistsQuery normsExistsQuery = (NormsFieldExistsQuery) constantScoreQuery.getQuery(); NormsFieldExistsQuery normsExistsQuery = (NormsFieldExistsQuery) constantScoreQuery.getQuery();
assertEquals(field, normsExistsQuery.getField()); assertEquals(field, normsExistsQuery.getField());

View File

@ -82,7 +82,7 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
query.to(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.format(end)); query.to(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.format(end));
// Create timestamp option only then we have a date mapper, // Create timestamp option only then we have a date mapper,
// otherwise we could trigger exception. // otherwise we could trigger exception.
if (createShardContext().getMapperService().fullName(DATE_FIELD_NAME) != null) { if (createShardContext().getMapperService().fieldType(DATE_FIELD_NAME) != null) {
if (randomBoolean()) { if (randomBoolean()) {
query.timeZone(randomZone().getId()); query.timeZone(randomZone().getId());
} }
@ -139,10 +139,10 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
if (queryBuilder.from() == null && queryBuilder.to() == null) { if (queryBuilder.from() == null && queryBuilder.to() == null) {
final Query expectedQuery; final Query expectedQuery;
if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_6_1_0) if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_6_1_0)
&& context.getMapperService().fullName(queryBuilder.fieldName()).hasDocValues()) { && context.getMapperService().fieldType(queryBuilder.fieldName()).hasDocValues()) {
expectedQuery = new ConstantScoreQuery(new DocValuesFieldExistsQuery(expectedFieldName)); expectedQuery = new ConstantScoreQuery(new DocValuesFieldExistsQuery(expectedFieldName));
} else if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_6_1_0) && } else if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_6_1_0) &&
context.getMapperService().fullName(queryBuilder.fieldName()).omitNorms() == false) { context.getMapperService().fieldType(queryBuilder.fieldName()).omitNorms() == false) {
expectedQuery = new ConstantScoreQuery(new NormsFieldExistsQuery(expectedFieldName)); expectedQuery = new ConstantScoreQuery(new NormsFieldExistsQuery(expectedFieldName));
} else { } else {
expectedQuery = new ConstantScoreQuery(new TermQuery(new Term(FieldNamesFieldMapper.NAME, expectedFieldName))); expectedQuery = new ConstantScoreQuery(new TermQuery(new Term(FieldNamesFieldMapper.NAME, expectedFieldName)));
@ -164,7 +164,7 @@ public class RangeQueryBuilderTests extends AbstractQueryTestCase<RangeQueryBuil
query = ((IndexOrDocValuesQuery) query).getIndexQuery(); query = ((IndexOrDocValuesQuery) query).getIndexQuery();
assertThat(query, instanceOf(PointRangeQuery.class)); assertThat(query, instanceOf(PointRangeQuery.class));
MapperService mapperService = context.getMapperService(); MapperService mapperService = context.getMapperService();
MappedFieldType mappedFieldType = mapperService.fullName(expectedFieldName); MappedFieldType mappedFieldType = mapperService.fieldType(expectedFieldName);
final Long fromInMillis; final Long fromInMillis;
final Long toInMillis; final Long toInMillis;
// we have to normalize the incoming value into milliseconds since it could be literally anything // we have to normalize the incoming value into milliseconds since it could be literally anything

View File

@ -63,7 +63,7 @@ public class ScoreFunctionBuilderTests extends ESTestCase {
MapperService mapperService = Mockito.mock(MapperService.class); MapperService mapperService = Mockito.mock(MapperService.class);
MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.LONG); MappedFieldType ft = new NumberFieldMapper.NumberFieldType(NumberType.LONG);
ft.setName("foo"); ft.setName("foo");
Mockito.when(mapperService.fullName(Mockito.anyString())).thenReturn(ft); Mockito.when(mapperService.fieldType(Mockito.anyString())).thenReturn(ft);
Mockito.when(context.getMapperService()).thenReturn(mapperService); Mockito.when(context.getMapperService()).thenReturn(mapperService);
builder.toFunction(context); builder.toFunction(context);
assertWarnings("As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"); assertWarnings("As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set");

View File

@ -118,28 +118,28 @@ public class NestedHelperTests extends ESSingleNodeTestCase {
} }
public void testTermsQuery() { public void testTermsQuery() {
Query termsQuery = mapperService.fullName("foo").termsQuery(Collections.singletonList("bar"), null); Query termsQuery = mapperService.fieldType("foo").termsQuery(Collections.singletonList("bar"), null);
assertFalse(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery)); assertFalse(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested_missing"));
termsQuery = mapperService.fullName("nested1.foo").termsQuery(Collections.singletonList("bar"), null); termsQuery = mapperService.fieldType("nested1.foo").termsQuery(Collections.singletonList("bar"), null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery));
assertFalse(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1")); assertFalse(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested_missing"));
termsQuery = mapperService.fullName("nested2.foo").termsQuery(Collections.singletonList("bar"), null); termsQuery = mapperService.fieldType("nested2.foo").termsQuery(Collections.singletonList("bar"), null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested_missing"));
termsQuery = mapperService.fullName("nested3.foo").termsQuery(Collections.singletonList("bar"), null); termsQuery = mapperService.fieldType("nested3.foo").termsQuery(Collections.singletonList("bar"), null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termsQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termsQuery, "nested2"));
@ -148,28 +148,28 @@ public class NestedHelperTests extends ESSingleNodeTestCase {
} }
public void testTermQuery() { public void testTermQuery() {
Query termQuery = mapperService.fullName("foo").termQuery("bar", null); Query termQuery = mapperService.fieldType("foo").termQuery("bar", null);
assertFalse(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery)); assertFalse(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested_missing"));
termQuery = mapperService.fullName("nested1.foo").termQuery("bar", null); termQuery = mapperService.fieldType("nested1.foo").termQuery("bar", null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery));
assertFalse(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1")); assertFalse(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested_missing"));
termQuery = mapperService.fullName("nested2.foo").termQuery("bar", null); termQuery = mapperService.fieldType("nested2.foo").termQuery("bar", null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested_missing"));
termQuery = mapperService.fullName("nested3.foo").termQuery("bar", null); termQuery = mapperService.fieldType("nested3.foo").termQuery("bar", null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(termQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(termQuery, "nested2"));
@ -178,28 +178,28 @@ public class NestedHelperTests extends ESSingleNodeTestCase {
} }
public void testRangeQuery() { public void testRangeQuery() {
Query rangeQuery = mapperService.fullName("foo2").rangeQuery(2, 5, true, true, null, null, null, null); Query rangeQuery = mapperService.fieldType("foo2").rangeQuery(2, 5, true, true, null, null, null, null);
assertFalse(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery)); assertFalse(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested_missing"));
rangeQuery = mapperService.fullName("nested1.foo2").rangeQuery(2, 5, true, true, null, null, null, null); rangeQuery = mapperService.fieldType("nested1.foo2").rangeQuery(2, 5, true, true, null, null, null, null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery));
assertFalse(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1")); assertFalse(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested_missing"));
rangeQuery = mapperService.fullName("nested2.foo2").rangeQuery(2, 5, true, true, null, null, null, null); rangeQuery = mapperService.fieldType("nested2.foo2").rangeQuery(2, 5, true, true, null, null, null, null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested3")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested3"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested_missing")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested_missing"));
rangeQuery = mapperService.fullName("nested3.foo2").rangeQuery(2, 5, true, true, null, null, null, null); rangeQuery = mapperService.fieldType("nested3.foo2").rangeQuery(2, 5, true, true, null, null, null, null);
assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery)); assertTrue(new NestedHelper(mapperService).mightMatchNestedDocs(rangeQuery));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested1"));
assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2")); assertTrue(new NestedHelper(mapperService).mightMatchNonNestedDocs(rangeQuery, "nested2"));

View File

@ -2450,7 +2450,7 @@ public class IndexShardTests extends IndexShardTestCase {
shard.refresh("created segment 2"); shard.refresh("created segment 2");
// test global ordinals are evicted // test global ordinals are evicted
MappedFieldType foo = shard.mapperService().fullName("foo"); MappedFieldType foo = shard.mapperService().fieldType("foo");
IndicesFieldDataCache indicesFieldDataCache = new IndicesFieldDataCache(shard.indexSettings.getNodeSettings(), IndicesFieldDataCache indicesFieldDataCache = new IndicesFieldDataCache(shard.indexSettings.getNodeSettings(),
new IndexFieldDataCache.Listener() {}); new IndexFieldDataCache.Listener() {});
IndexFieldDataService indexFieldDataService = new IndexFieldDataService(shard.indexSettings, indicesFieldDataCache, IndexFieldDataService indexFieldDataService = new IndexFieldDataService(shard.indexSettings, indicesFieldDataCache,

View File

@ -83,9 +83,9 @@ public class LegacySimilarityTests extends ESSingleNodeTestCase {
.put("index.similarity.my_similarity.discount_overlaps", false) .put("index.similarity.my_similarity.discount_overlaps", false)
.build(); .build();
final MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); final MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(ClassicSimilarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(ClassicSimilarity.class));
final ClassicSimilarity similarity = (ClassicSimilarity) mapperService.fullName("field1").similarity().get(); final ClassicSimilarity similarity = (ClassicSimilarity) mapperService.fieldType("field1").similarity().get();
assertThat(similarity.getDiscountOverlaps(), equalTo(false)); assertThat(similarity.getDiscountOverlaps(), equalTo(false));
} }
} }

View File

@ -94,9 +94,9 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.put("index.similarity.my_similarity.discount_overlaps", false) .put("index.similarity.my_similarity.discount_overlaps", false)
.build(); .build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(LegacyBM25Similarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(LegacyBM25Similarity.class));
LegacyBM25Similarity similarity = (LegacyBM25Similarity) mapperService.fullName("field1").similarity().get(); LegacyBM25Similarity similarity = (LegacyBM25Similarity) mapperService.fieldType("field1").similarity().get();
assertThat(similarity.getK1(), equalTo(2.0f)); assertThat(similarity.getK1(), equalTo(2.0f));
assertThat(similarity.getB(), equalTo(0.5f)); assertThat(similarity.getB(), equalTo(0.5f));
assertThat(similarity.getDiscountOverlaps(), equalTo(false)); assertThat(similarity.getDiscountOverlaps(), equalTo(false));
@ -110,7 +110,7 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("foo", Settings.EMPTY, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", Settings.EMPTY, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(BooleanSimilarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(BooleanSimilarity.class));
} }
public void testResolveSimilaritiesFromMapping_DFR() throws IOException { public void testResolveSimilaritiesFromMapping_DFR() throws IOException {
@ -128,9 +128,9 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.put("index.similarity.my_similarity.normalization.h2.c", 3f) .put("index.similarity.my_similarity.normalization.h2.c", 3f)
.build(); .build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(DFRSimilarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(DFRSimilarity.class));
DFRSimilarity similarity = (DFRSimilarity) mapperService.fullName("field1").similarity().get(); DFRSimilarity similarity = (DFRSimilarity) mapperService.fieldType("field1").similarity().get();
assertThat(similarity.getBasicModel(), instanceOf(BasicModelG.class)); assertThat(similarity.getBasicModel(), instanceOf(BasicModelG.class));
assertThat(similarity.getAfterEffect(), instanceOf(AfterEffectL.class)); assertThat(similarity.getAfterEffect(), instanceOf(AfterEffectL.class));
assertThat(similarity.getNormalization(), instanceOf(NormalizationH2.class)); assertThat(similarity.getNormalization(), instanceOf(NormalizationH2.class));
@ -152,9 +152,9 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.put("index.similarity.my_similarity.normalization.h2.c", 3f) .put("index.similarity.my_similarity.normalization.h2.c", 3f)
.build(); .build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(IBSimilarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(IBSimilarity.class));
IBSimilarity similarity = (IBSimilarity) mapperService.fullName("field1").similarity().get(); IBSimilarity similarity = (IBSimilarity) mapperService.fieldType("field1").similarity().get();
assertThat(similarity.getDistribution(), instanceOf(DistributionSPL.class)); assertThat(similarity.getDistribution(), instanceOf(DistributionSPL.class));
assertThat(similarity.getLambda(), instanceOf(LambdaTTF.class)); assertThat(similarity.getLambda(), instanceOf(LambdaTTF.class));
assertThat(similarity.getNormalization(), instanceOf(NormalizationH2.class)); assertThat(similarity.getNormalization(), instanceOf(NormalizationH2.class));
@ -173,7 +173,7 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.put("index.similarity.my_similarity.independence_measure", "chisquared") .put("index.similarity.my_similarity.independence_measure", "chisquared")
.build(); .build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
MappedFieldType fieldType = mapperService.fullName("field1"); MappedFieldType fieldType = mapperService.fieldType("field1");
assertThat(fieldType.similarity().get(), instanceOf(DFISimilarity.class)); assertThat(fieldType.similarity().get(), instanceOf(DFISimilarity.class));
DFISimilarity similarity = (DFISimilarity) fieldType.similarity().get(); DFISimilarity similarity = (DFISimilarity) fieldType.similarity().get();
@ -193,9 +193,9 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.build(); .build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(LMDirichletSimilarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(LMDirichletSimilarity.class));
LMDirichletSimilarity similarity = (LMDirichletSimilarity) mapperService.fullName("field1").similarity().get(); LMDirichletSimilarity similarity = (LMDirichletSimilarity) mapperService.fieldType("field1").similarity().get();
assertThat(similarity.getMu(), equalTo(3000f)); assertThat(similarity.getMu(), equalTo(3000f));
} }
@ -211,9 +211,9 @@ public class SimilarityTests extends ESSingleNodeTestCase {
.put("index.similarity.my_similarity.lambda", 0.7f) .put("index.similarity.my_similarity.lambda", 0.7f)
.build(); .build();
MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService(); MapperService mapperService = createIndex("foo", indexSettings, "type", mapping).mapperService();
assertThat(mapperService.fullName("field1").similarity().get(), instanceOf(LMJelinekMercerSimilarity.class)); assertThat(mapperService.fieldType("field1").similarity().get(), instanceOf(LMJelinekMercerSimilarity.class));
LMJelinekMercerSimilarity similarity = (LMJelinekMercerSimilarity) mapperService.fullName("field1").similarity().get(); LMJelinekMercerSimilarity similarity = (LMJelinekMercerSimilarity) mapperService.fieldType("field1").similarity().get();
assertThat(similarity.getLambda(), equalTo(0.7f)); assertThat(similarity.getLambda(), equalTo(0.7f));
} }

View File

@ -304,7 +304,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
assertThat("index service doesn't exists on " + node, indexService, notNullValue()); assertThat("index service doesn't exists on " + node, indexService, notNullValue());
MapperService mapperService = indexService.mapperService(); MapperService mapperService = indexService.mapperService();
for (String fieldName : fieldNames) { for (String fieldName : fieldNames) {
MappedFieldType fieldType = mapperService.fullName(fieldName); MappedFieldType fieldType = mapperService.fieldType(fieldName);
assertNotNull("field " + fieldName + " doesn't exists on " + node, fieldType); assertNotNull("field " + fieldName + " doesn't exists on " + node, fieldType);
} }
} }

View File

@ -72,7 +72,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
// left orientation test // left orientation test
IndicesService indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName)); IndicesService indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName));
IndexService indexService = indicesService.indexService(resolveIndex(idxName)); IndexService indexService = indicesService.indexService(resolveIndex(idxName));
MappedFieldType fieldType = indexService.mapperService().fullName("location"); MappedFieldType fieldType = indexService.mapperService().fieldType("location");
assertThat(fieldType, instanceOf(GeoShapeFieldMapper.GeoShapeFieldType.class)); assertThat(fieldType, instanceOf(GeoShapeFieldMapper.GeoShapeFieldType.class));
GeoShapeFieldMapper.GeoShapeFieldType gsfm = (GeoShapeFieldMapper.GeoShapeFieldType)fieldType; GeoShapeFieldMapper.GeoShapeFieldType gsfm = (GeoShapeFieldMapper.GeoShapeFieldType)fieldType;
@ -84,7 +84,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
// right orientation test // right orientation test
indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName+"2")); indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName+"2"));
indexService = indicesService.indexService(resolveIndex((idxName+"2"))); indexService = indicesService.indexService(resolveIndex((idxName+"2")));
fieldType = indexService.mapperService().fullName("location"); fieldType = indexService.mapperService().fieldType("location");
assertThat(fieldType, instanceOf(GeoShapeFieldMapper.GeoShapeFieldType.class)); assertThat(fieldType, instanceOf(GeoShapeFieldMapper.GeoShapeFieldType.class));
gsfm = (GeoShapeFieldMapper.GeoShapeFieldType)fieldType; gsfm = (GeoShapeFieldMapper.GeoShapeFieldType)fieldType;

View File

@ -74,7 +74,7 @@ public class LegacyGeoShapeIntegrationIT extends ESIntegTestCase {
// left orientation test // left orientation test
IndicesService indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName)); IndicesService indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName));
IndexService indexService = indicesService.indexService(resolveIndex(idxName)); IndexService indexService = indicesService.indexService(resolveIndex(idxName));
MappedFieldType fieldType = indexService.mapperService().fullName("location"); MappedFieldType fieldType = indexService.mapperService().fieldType("location");
assertThat(fieldType, instanceOf(LegacyGeoShapeFieldMapper.GeoShapeFieldType.class)); assertThat(fieldType, instanceOf(LegacyGeoShapeFieldMapper.GeoShapeFieldType.class));
LegacyGeoShapeFieldMapper.GeoShapeFieldType gsfm = (LegacyGeoShapeFieldMapper.GeoShapeFieldType)fieldType; LegacyGeoShapeFieldMapper.GeoShapeFieldType gsfm = (LegacyGeoShapeFieldMapper.GeoShapeFieldType)fieldType;
@ -86,7 +86,7 @@ public class LegacyGeoShapeIntegrationIT extends ESIntegTestCase {
// right orientation test // right orientation test
indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName+"2")); indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName+"2"));
indexService = indicesService.indexService(resolveIndex((idxName+"2"))); indexService = indicesService.indexService(resolveIndex((idxName+"2")));
fieldType = indexService.mapperService().fullName("location"); fieldType = indexService.mapperService().fieldType("location");
assertThat(fieldType, instanceOf(LegacyGeoShapeFieldMapper.GeoShapeFieldType.class)); assertThat(fieldType, instanceOf(LegacyGeoShapeFieldMapper.GeoShapeFieldType.class));
gsfm = (LegacyGeoShapeFieldMapper.GeoShapeFieldType)fieldType; gsfm = (LegacyGeoShapeFieldMapper.GeoShapeFieldType)fieldType;

View File

@ -46,9 +46,9 @@ public class LeafDocLookupTests extends ESTestCase {
when(fieldType.valueForDisplay(anyObject())).then(returnsFirstArg()); when(fieldType.valueForDisplay(anyObject())).then(returnsFirstArg());
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName("_type")).thenReturn(fieldType); when(mapperService.fieldType("_type")).thenReturn(fieldType);
when(mapperService.fullName("field")).thenReturn(fieldType); when(mapperService.fieldType("field")).thenReturn(fieldType);
when(mapperService.fullName("alias")).thenReturn(fieldType); when(mapperService.fieldType("alias")).thenReturn(fieldType);
docValues = mock(ScriptDocValues.class); docValues = mock(ScriptDocValues.class);
IndexFieldData<?> fieldData = createFieldData(docValues); IndexFieldData<?> fieldData = createFieldData(docValues);

View File

@ -52,8 +52,8 @@ public class LeafFieldsLookupTests extends ESTestCase {
(Double) invocation.getArguments()[0] + 10); (Double) invocation.getArguments()[0] + 10);
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName("field")).thenReturn(fieldType); when(mapperService.fieldType("field")).thenReturn(fieldType);
when(mapperService.fullName("alias")).thenReturn(fieldType); when(mapperService.fieldType("alias")).thenReturn(fieldType);
FieldInfo mockFieldInfo = new FieldInfo("field", 1, false, false, true, FieldInfo mockFieldInfo = new FieldInfo("field", 1, false, false, true,
IndexOptions.NONE, DocValuesType.NONE, -1, Collections.emptyMap(), 0, 0, 0, false); IndexOptions.NONE, DocValuesType.NONE, -1, Collections.emptyMap(), 0, 0, 0, false);

View File

@ -643,8 +643,8 @@ public class QueryPhaseTests extends IndexShardTestCase {
MappedFieldType fieldTypeLong = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG); MappedFieldType fieldTypeLong = new NumberFieldMapper.NumberFieldType(NumberFieldMapper.NumberType.LONG);
MappedFieldType fieldTypeDate = new DateFieldMapper.Builder(fieldNameDate).fieldType(); MappedFieldType fieldTypeDate = new DateFieldMapper.Builder(fieldNameDate).fieldType();
MapperService mapperService = mock(MapperService.class); MapperService mapperService = mock(MapperService.class);
when(mapperService.fullName(fieldNameLong)).thenReturn(fieldTypeLong); when(mapperService.fieldType(fieldNameLong)).thenReturn(fieldTypeLong);
when(mapperService.fullName(fieldNameDate)).thenReturn(fieldTypeDate); when(mapperService.fieldType(fieldNameDate)).thenReturn(fieldTypeDate);
final int numDocs = 7000; final int numDocs = 7000;
Directory dir = newDirectory(); Directory dir = newDirectory();

View File

@ -174,7 +174,7 @@ public abstract class AbstractSuggestionBuilderTestCase<SB extends SuggestionBui
when(mapperService.searchAnalyzer()) when(mapperService.searchAnalyzer())
.thenReturn(new NamedAnalyzer("mapperServiceSearchAnalyzer", AnalyzerScope.INDEX, new SimpleAnalyzer())); .thenReturn(new NamedAnalyzer("mapperServiceSearchAnalyzer", AnalyzerScope.INDEX, new SimpleAnalyzer()));
} }
when(mapperService.fullName(any(String.class))).thenReturn(fieldType); when(mapperService.fieldType(any(String.class))).thenReturn(fieldType);
when(mapperService.getNamedAnalyzer(any(String.class))).then( when(mapperService.getNamedAnalyzer(any(String.class))).then(
invocation -> new NamedAnalyzer((String) invocation.getArguments()[0], AnalyzerScope.INDEX, new SimpleAnalyzer())); invocation -> new NamedAnalyzer((String) invocation.getArguments()[0], AnalyzerScope.INDEX, new SimpleAnalyzer()));
when(scriptService.compile(any(Script.class), any())).then(invocation -> new TestTemplateService.MockTemplateScript.Factory( when(scriptService.compile(any(Script.class), any())).then(invocation -> new TestTemplateService.MockTemplateScript.Factory(

View File

@ -718,7 +718,7 @@ public class CategoryContextMappingTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
CompletionFieldType completionFieldType = (CompletionFieldType) mapperService.fullName("completion"); CompletionFieldType completionFieldType = (CompletionFieldType) mapperService.fieldType("completion");
Exception e = expectThrows(IllegalArgumentException.class, () -> completionFieldType.getContextMappings().get("brand")); Exception e = expectThrows(IllegalArgumentException.class, () -> completionFieldType.getContextMappings().get("brand"));
assertEquals("Unknown context name [brand], must be one of [ctx, type]", e.getMessage()); assertEquals("Unknown context name [brand], must be one of [ctx, type]", e.getMessage());

View File

@ -62,7 +62,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
MappedFieldType completionFieldType = mapperService.fullName("completion"); MappedFieldType completionFieldType = mapperService.fieldType("completion");
ParsedDocument parsedDocument = mapperService.documentMapper().parse(new SourceToParse("test", "type1", "1", ParsedDocument parsedDocument = mapperService.documentMapper().parse(new SourceToParse("test", "type1", "1",
BytesReference.bytes(jsonBuilder() BytesReference.bytes(jsonBuilder()
.startObject() .startObject()
@ -101,7 +101,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
MappedFieldType completionFieldType = mapperService.fullName("completion"); MappedFieldType completionFieldType = mapperService.fieldType("completion");
ParsedDocument parsedDocument = mapperService.documentMapper().parse(new SourceToParse("test", "type1", "1", ParsedDocument parsedDocument = mapperService.documentMapper().parse(new SourceToParse("test", "type1", "1",
BytesReference.bytes(jsonBuilder() BytesReference.bytes(jsonBuilder()
.startObject() .startObject()
@ -137,7 +137,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
MappedFieldType completionFieldType = mapperService.fullName("completion"); MappedFieldType completionFieldType = mapperService.fieldType("completion");
ParsedDocument parsedDocument = mapperService.documentMapper().parse(new SourceToParse("test", "type1", "1", ParsedDocument parsedDocument = mapperService.documentMapper().parse(new SourceToParse("test", "type1", "1",
BytesReference.bytes(jsonBuilder() BytesReference.bytes(jsonBuilder()
.startObject() .startObject()
@ -181,7 +181,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
.endObject().endObject(); .endObject().endObject();
MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService(); MapperService mapperService = createIndex("test", Settings.EMPTY, "type1", mapping).mapperService();
MappedFieldType completionFieldType = mapperService.fullName("completion"); MappedFieldType completionFieldType = mapperService.fieldType("completion");
XContentBuilder builder = jsonBuilder() XContentBuilder builder = jsonBuilder()
.startObject() .startObject()
.startArray("completion") .startArray("completion")

View File

@ -122,7 +122,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
String fieldName = entry.getKey(); String fieldName = entry.getKey();
MappedFieldType fieldType = entry.getValue(); MappedFieldType fieldType = entry.getValue();
when(mapperService.fullName(fieldName)).thenReturn(fieldType); when(mapperService.fieldType(fieldName)).thenReturn(fieldType);
when(searchContext.smartNameFieldType(fieldName)).thenReturn(fieldType); when(searchContext.smartNameFieldType(fieldName)).thenReturn(fieldType);
} }
} }

View File

@ -577,7 +577,7 @@ public class TestSearchContext extends SearchContext {
@Override @Override
public MappedFieldType smartNameFieldType(String name) { public MappedFieldType smartNameFieldType(String name) {
if (mapperService() != null) { if (mapperService() != null) {
return mapperService().fullName(name); return mapperService().fieldType(name);
} }
return null; return null;
} }

View File

@ -158,10 +158,10 @@ public class FlatObjectFieldLookupTests extends ESTestCase {
IndexFieldData<?> fieldData2 = createFieldData(docValues2); IndexFieldData<?> fieldData2 = createFieldData(docValues2);
KeyedFlatObjectFieldType fieldType1 = new KeyedFlatObjectFieldType("key1"); KeyedFlatObjectFieldType fieldType1 = new KeyedFlatObjectFieldType("key1");
when(mapperService.fullName("json.key1")).thenReturn(fieldType1); when(mapperService.fieldType("json.key1")).thenReturn(fieldType1);
KeyedFlatObjectFieldType fieldType2 = new KeyedFlatObjectFieldType( "key2"); KeyedFlatObjectFieldType fieldType2 = new KeyedFlatObjectFieldType( "key2");
when(mapperService.fullName("json.key2")).thenReturn(fieldType2); when(mapperService.fieldType("json.key2")).thenReturn(fieldType2);
Function<MappedFieldType, IndexFieldData<?>> fieldDataSupplier = fieldType -> { Function<MappedFieldType, IndexFieldData<?>> fieldDataSupplier = fieldType -> {
KeyedFlatObjectFieldType keyedFieldType = (KeyedFlatObjectFieldType) fieldType; KeyedFlatObjectFieldType keyedFieldType = (KeyedFlatObjectFieldType) fieldType;

View File

@ -480,12 +480,12 @@ public class FlatObjectFieldMapperTests extends ESSingleNodeTestCase {
.endObject().endObject()); .endObject().endObject());
mapperService.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE); mapperService.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
RootFlatObjectFieldType rootFieldType = (RootFlatObjectFieldType) mapperService.fullName("field"); RootFlatObjectFieldType rootFieldType = (RootFlatObjectFieldType) mapperService.fieldType("field");
assertThat(rootFieldType.searchAnalyzer().name(), equalTo("whitespace")); assertThat(rootFieldType.searchAnalyzer().name(), equalTo("whitespace"));
assertTokenStreamContents(rootFieldType.searchAnalyzer().analyzer().tokenStream("", "Hello World"), assertTokenStreamContents(rootFieldType.searchAnalyzer().analyzer().tokenStream("", "Hello World"),
new String[] {"Hello", "World"}); new String[] {"Hello", "World"});
KeyedFlatObjectFieldType keyedFieldType = (KeyedFlatObjectFieldType) mapperService.fullName("field.key"); KeyedFlatObjectFieldType keyedFieldType = (KeyedFlatObjectFieldType) mapperService.fieldType("field.key");
assertThat(keyedFieldType.searchAnalyzer().name(), equalTo("whitespace")); assertThat(keyedFieldType.searchAnalyzer().name(), equalTo("whitespace"));
assertTokenStreamContents(keyedFieldType.searchAnalyzer().analyzer().tokenStream("", "Hello World"), assertTokenStreamContents(keyedFieldType.searchAnalyzer().analyzer().tokenStream("", "Hello World"),
new String[] {"Hello", "World"}); new String[] {"Hello", "World"});