From 41c7d3e0920b851fad990a8e4fdaa7f667ad341a Mon Sep 17 00:00:00 2001 From: javanna Date: Sat, 31 Dec 2016 11:31:09 +0100 Subject: [PATCH] Remove ParseFieldMatcher usage from Mappers --- .../src/main/resources/checkstyle_suppressions.xml | 2 -- .../index/mapper/DocumentMapperParser.java | 12 ++++++------ .../org/elasticsearch/index/mapper/Mapper.java | 14 +++----------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml index 258dafae20d..dac28d61a8d 100644 --- a/buildSrc/src/main/resources/checkstyle_suppressions.xml +++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml @@ -349,12 +349,10 @@ - - diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java index d05cec27b2e..031f1390756 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -52,7 +51,6 @@ public class DocumentMapperParser { private final RootObjectMapper.TypeParser rootObjectTypeParser = new RootObjectMapper.TypeParser(); private final Version indexVersionCreated; - private final ParseFieldMatcher parseFieldMatcher; private final Map typeParsers; private final Map rootTypeParsers; @@ -60,7 +58,6 @@ public class DocumentMapperParser { public DocumentMapperParser(IndexSettings indexSettings, MapperService mapperService, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, Supplier queryShardContextSupplier) { - this.parseFieldMatcher = new ParseFieldMatcher(indexSettings.getSettings()); this.mapperService = mapperService; this.indexAnalyzers = indexAnalyzers; this.xContentRegistry = xContentRegistry; @@ -72,7 +69,8 @@ public class DocumentMapperParser { } public Mapper.TypeParser.ParserContext parserContext(String type) { - return new Mapper.TypeParser.ParserContext(type, indexAnalyzers, similarityService::getSimilarity, mapperService, typeParsers::get, indexVersionCreated, parseFieldMatcher, queryShardContextSupplier); + return new Mapper.TypeParser.ParserContext(type, indexAnalyzers, similarityService::getSimilarity, mapperService, + typeParsers::get, indexVersionCreated, queryShardContextSupplier); } public DocumentMapper parse(@Nullable String type, CompressedXContent source) throws MapperParsingException { @@ -109,7 +107,8 @@ public class DocumentMapperParser { Mapper.TypeParser.ParserContext parserContext = parserContext(type); // parse RootObjectMapper - DocumentMapper.Builder docBuilder = new DocumentMapper.Builder((RootObjectMapper.Builder) rootObjectTypeParser.parse(type, mapping, parserContext), mapperService); + DocumentMapper.Builder docBuilder = new DocumentMapper.Builder( + (RootObjectMapper.Builder) rootObjectTypeParser.parse(type, mapping, parserContext), mapperService); Iterator> iterator = mapping.entrySet().iterator(); // parse DocumentMapper while(iterator.hasNext()) { @@ -143,7 +142,8 @@ public class DocumentMapperParser { } public static void checkNoRemainingFields(String fieldName, Map fieldNodeMap, Version indexVersionCreated) { - checkNoRemainingFields(fieldNodeMap, indexVersionCreated, "Mapping definition for [" + fieldName + "] has unsupported parameters: "); + checkNoRemainingFields(fieldNodeMap, indexVersionCreated, + "Mapping definition for [" + fieldName + "] has unsupported parameters: "); } public static void checkNoRemainingFields(Map fieldNodeMap, Version indexVersionCreated, String message) { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java b/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java index 384331c2d9e..db1060d3be6 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/Mapper.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.Version; -import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.index.analysis.IndexAnalyzers; @@ -91,21 +90,17 @@ public abstract class Mapper implements ToXContent, Iterable { private final Version indexVersionCreated; - private final ParseFieldMatcher parseFieldMatcher; - private final Supplier queryShardContextSupplier; public ParserContext(String type, IndexAnalyzers indexAnalyzers, Function similarityLookupService, MapperService mapperService, Function typeParsers, - Version indexVersionCreated, ParseFieldMatcher parseFieldMatcher, - Supplier queryShardContextSupplier) { + Version indexVersionCreated, Supplier queryShardContextSupplier) { this.type = type; this.indexAnalyzers = indexAnalyzers; this.similarityLookupService = similarityLookupService; this.mapperService = mapperService; this.typeParsers = typeParsers; this.indexVersionCreated = indexVersionCreated; - this.parseFieldMatcher = parseFieldMatcher; this.queryShardContextSupplier = queryShardContextSupplier; } @@ -133,10 +128,6 @@ public abstract class Mapper implements ToXContent, Iterable { return indexVersionCreated; } - public ParseFieldMatcher parseFieldMatcher() { - return parseFieldMatcher; - } - public Supplier queryShardContextSupplier() { return queryShardContextSupplier; } @@ -156,7 +147,8 @@ public abstract class Mapper implements ToXContent, Iterable { static class MultiFieldParserContext extends ParserContext { MultiFieldParserContext(ParserContext in) { - super(in.type(), in.indexAnalyzers, in.similarityLookupService(), in.mapperService(), in.typeParsers(), in.indexVersionCreated(), in.parseFieldMatcher(), in.queryShardContextSupplier()); + super(in.type(), in.indexAnalyzers, in.similarityLookupService(), in.mapperService(), in.typeParsers(), + in.indexVersionCreated(), in.queryShardContextSupplier()); } }