From e95097c33cc782a3ca83b7ea6cafedc3d6793fd3 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 18 May 2015 22:41:56 -0700 Subject: [PATCH] Mappings: Remove SmartNameFieldMappers This change simplifies the users of the mapper service to no longer have access to multiple fields for a single name. While FieldMappersLookup still stores and gives access to multiple fields, the current users of SmartNameFieldMappers already all assumed a single field. The arbitrary selection of that field when multiple exist is now isolated to the mapper service. --- .../classic/MapperQueryParser.java | 134 +++++------- .../TransportFieldStatsTransportAction.java | 7 +- .../PerFieldMappingPostingFormatCodec.java | 13 +- .../index/fieldvisitor/FieldsVisitor.java | 4 +- .../index/mapper/MapperService.java | 203 +++--------------- .../index/query/CommonTermsQueryParser.java | 15 +- .../index/query/ExistsQueryParser.java | 15 +- .../index/query/FuzzyQueryParser.java | 11 +- .../query/GeoBoundingBoxQueryParser.java | 6 +- .../index/query/GeoDistanceQueryParser.java | 6 +- .../query/GeoDistanceRangeQueryParser.java | 6 +- .../index/query/GeoPolygonQueryParser.java | 6 +- .../index/query/GeoShapeQueryParser.java | 6 +- .../index/query/GeohashCellQuery.java | 6 +- .../index/query/MissingQueryParser.java | 21 +- .../index/query/MoreLikeThisQueryParser.java | 5 +- .../index/query/PrefixQueryParser.java | 8 +- .../index/query/QueryParseContext.java | 45 ++-- .../index/query/RangeQueryParser.java | 35 ++- .../index/query/RegexpQueryParser.java | 9 +- .../index/query/SimpleQueryStringParser.java | 8 +- .../index/query/SpanTermQueryParser.java | 12 +- .../index/query/TermQueryParser.java | 8 +- .../index/query/TermsQueryParser.java | 12 +- .../index/query/WildcardQueryParser.java | 10 +- .../functionscore/DecayFunctionParser.java | 6 +- .../index/search/MatchQuery.java | 26 +-- .../index/search/MultiMatchQuery.java | 11 +- .../indices/ttl/IndicesTTLService.java | 11 +- .../percolator/PercolateContext.java | 10 - .../search/fetch/FetchPhase.java | 16 +- .../search/internal/DefaultSearchContext.java | 10 - .../internal/FilteredSearchContext.java | 10 - .../search/internal/SearchContext.java | 4 - .../index/mapper/DynamicMappingTests.java | 4 +- .../elasticsearch/test/TestSearchContext.java | 10 - 36 files changed, 240 insertions(+), 489 deletions(-) diff --git a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java index c3e768c5ea3..84fcc62af81 100644 --- a/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java +++ b/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java @@ -227,27 +227,25 @@ public class MapperQueryParser extends QueryParser { currentMapper = null; Analyzer oldAnalyzer = getAnalyzer(); try { - MapperService.SmartNameFieldMappers fieldMappers = null; if (quoted) { setAnalyzer(quoteAnalyzer); if (quoteFieldSuffix != null) { - fieldMappers = parseContext.smartFieldMappers(field + quoteFieldSuffix); + currentMapper = parseContext.fieldMapper(field + quoteFieldSuffix); } } - if (fieldMappers == null) { - fieldMappers = parseContext.smartFieldMappers(field); + if (currentMapper == null) { + currentMapper = parseContext.fieldMapper(field); } - if (fieldMappers != null) { + if (currentMapper != null) { if (quoted) { if (!forcedQuoteAnalyzer) { - setAnalyzer(fieldMappers.searchQuoteAnalyzer()); + setAnalyzer(parseContext.getSearchQuoteAnalyzer(currentMapper)); } } else { if (!forcedAnalyzer) { - setAnalyzer(fieldMappers.searchAnalyzer()); + setAnalyzer(parseContext.getSearchAnalyzer(currentMapper)); } } - currentMapper = fieldMappers.fieldMappers().mapper(); if (currentMapper != null) { Query query = null; if (currentMapper.useTermQueryWithQueryString()) { @@ -363,32 +361,27 @@ public class MapperQueryParser extends QueryParser { } private Query getRangeQuerySingle(String field, String part1, String part2, boolean startInclusive, boolean endInclusive) { - currentMapper = null; - MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field); - if (fieldMappers != null) { - currentMapper = fieldMappers.fieldMappers().mapper(); - if (currentMapper != null) { + currentMapper = parseContext.fieldMapper(field); + if (currentMapper != null) { + if (lowercaseExpandedTerms && !currentMapper.isNumeric()) { + part1 = part1 == null ? null : part1.toLowerCase(locale); + part2 = part2 == null ? null : part2.toLowerCase(locale); + } - if (lowercaseExpandedTerms && !currentMapper.isNumeric()) { - part1 = part1 == null ? null : part1.toLowerCase(locale); - part2 = part2 == null ? null : part2.toLowerCase(locale); + try { + Query rangeQuery; + if (currentMapper instanceof DateFieldMapper && settings.timeZone() != null) { + DateFieldMapper dateFieldMapper = (DateFieldMapper) this.currentMapper; + rangeQuery = dateFieldMapper.rangeQuery(part1, part2, startInclusive, endInclusive, settings.timeZone(), null, parseContext); + } else { + rangeQuery = currentMapper.rangeQuery(part1, part2, startInclusive, endInclusive, parseContext); } - - try { - Query rangeQuery; - if (currentMapper instanceof DateFieldMapper && settings.timeZone() != null) { - DateFieldMapper dateFieldMapper = (DateFieldMapper) this.currentMapper; - rangeQuery = dateFieldMapper.rangeQuery(part1, part2, startInclusive, endInclusive, settings.timeZone(), null, parseContext); - } else { - rangeQuery = currentMapper.rangeQuery(part1, part2, startInclusive, endInclusive, parseContext); - } - return rangeQuery; - } catch (RuntimeException e) { - if (settings.lenient()) { - return null; - } - throw e; + return rangeQuery; + } catch (RuntimeException e) { + if (settings.lenient()) { + return null; } + throw e; } } return newRangeQuery(field, part1, part2, startInclusive, endInclusive); @@ -433,20 +426,16 @@ public class MapperQueryParser extends QueryParser { } private Query getFuzzyQuerySingle(String field, String termStr, String minSimilarity) throws ParseException { - currentMapper = null; - MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field); - if (fieldMappers != null) { - currentMapper = fieldMappers.fieldMappers().mapper(); - if (currentMapper != null) { - try { - //LUCENE 4 UPGRADE I disabled transpositions here by default - maybe this needs to be changed - return currentMapper.fuzzyQuery(termStr, Fuzziness.build(minSimilarity), fuzzyPrefixLength, settings.fuzzyMaxExpansions(), false); - } catch (RuntimeException e) { - if (settings.lenient()) { - return null; - } - throw e; + currentMapper = parseContext.fieldMapper(field); + if (currentMapper!= null) { + try { + //LUCENE 4 UPGRADE I disabled transpositions here by default - maybe this needs to be changed + return currentMapper.fuzzyQuery(termStr, Fuzziness.build(minSimilarity), fuzzyPrefixLength, settings.fuzzyMaxExpansions(), false); + } catch (RuntimeException e) { + if (settings.lenient()) { + return null; } + throw e; } } return super.getFuzzyQuery(field, termStr, Float.parseFloat(minSimilarity)); @@ -509,22 +498,19 @@ public class MapperQueryParser extends QueryParser { currentMapper = null; Analyzer oldAnalyzer = getAnalyzer(); try { - MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field); - if (fieldMappers != null) { + currentMapper = parseContext.fieldMapper(field); + if (currentMapper != null) { if (!forcedAnalyzer) { - setAnalyzer(fieldMappers.searchAnalyzer()); + setAnalyzer(parseContext.getSearchAnalyzer(currentMapper)); } - currentMapper = fieldMappers.fieldMappers().mapper(); - if (currentMapper != null) { - Query query = null; - if (currentMapper.useTermQueryWithQueryString()) { - query = currentMapper.prefixQuery(termStr, multiTermRewriteMethod, parseContext); - } - if (query == null) { - query = getPossiblyAnalyzedPrefixQuery(currentMapper.names().indexName(), termStr); - } - return query; + Query query = null; + if (currentMapper.useTermQueryWithQueryString()) { + query = currentMapper.prefixQuery(termStr, multiTermRewriteMethod, parseContext); } + if (query == null) { + query = getPossiblyAnalyzedPrefixQuery(currentMapper.names().indexName(), termStr); + } + return query; } return getPossiblyAnalyzedPrefixQuery(field, termStr); } catch (RuntimeException e) { @@ -653,15 +639,12 @@ public class MapperQueryParser extends QueryParser { currentMapper = null; Analyzer oldAnalyzer = getAnalyzer(); try { - MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field); - if (fieldMappers != null) { + currentMapper = parseContext.fieldMapper(field); + if (currentMapper != null) { if (!forcedAnalyzer) { - setAnalyzer(fieldMappers.searchAnalyzer()); - } - currentMapper = fieldMappers.fieldMappers().mapper(); - if (currentMapper != null) { - indexedNameField = currentMapper.names().indexName(); + setAnalyzer(parseContext.getSearchAnalyzer(currentMapper)); } + indexedNameField = currentMapper.names().indexName(); return getPossiblyAnalyzedWildcardQuery(indexedNameField, termStr); } return getPossiblyAnalyzedWildcardQuery(indexedNameField, termStr); @@ -788,22 +771,19 @@ public class MapperQueryParser extends QueryParser { currentMapper = null; Analyzer oldAnalyzer = getAnalyzer(); try { - MapperService.SmartNameFieldMappers fieldMappers = parseContext.smartFieldMappers(field); - if (fieldMappers != null) { + currentMapper = parseContext.fieldMapper(field); + if (currentMapper != null) { if (!forcedAnalyzer) { - setAnalyzer(fieldMappers.searchAnalyzer()); + setAnalyzer(parseContext.getSearchAnalyzer(currentMapper)); } - currentMapper = fieldMappers.fieldMappers().mapper(); - if (currentMapper != null) { - Query query = null; - if (currentMapper.useTermQueryWithQueryString()) { - query = currentMapper.regexpQuery(termStr, RegExp.ALL, maxDeterminizedStates, multiTermRewriteMethod, parseContext); - } - if (query == null) { - query = super.getRegexpQuery(field, termStr); - } - return query; + Query query = null; + if (currentMapper.useTermQueryWithQueryString()) { + query = currentMapper.regexpQuery(termStr, RegExp.ALL, maxDeterminizedStates, multiTermRewriteMethod, parseContext); } + if (query == null) { + query = super.getRegexpQuery(field, termStr); + } + return query; } return super.getRegexpQuery(field, termStr); } catch (RuntimeException e) { diff --git a/src/main/java/org/elasticsearch/action/fieldstats/TransportFieldStatsTransportAction.java b/src/main/java/org/elasticsearch/action/fieldstats/TransportFieldStatsTransportAction.java index 2816a655bb7..e9ed8abe62e 100644 --- a/src/main/java/org/elasticsearch/action/fieldstats/TransportFieldStatsTransportAction.java +++ b/src/main/java/org/elasticsearch/action/fieldstats/TransportFieldStatsTransportAction.java @@ -39,6 +39,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.Engine; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.shard.IndexShard; @@ -133,12 +134,12 @@ public class TransportFieldStatsTransportAction extends TransportBroadcastOperat shard.readAllowed(); try (Engine.Searcher searcher = shard.acquireSearcher("fieldstats")) { for (String field : request.getFields()) { - FieldMappers fieldMappers = mapperService.fullName(field); - if (fieldMappers != null) { + FieldMapper fieldMapper = mapperService.fullName(field); + if (fieldMapper != null) { IndexReader reader = searcher.reader(); Terms terms = MultiFields.getTerms(reader, field); if (terms != null) { - fieldStats.put(field, fieldMappers.mapper().stats(terms, reader.maxDoc())); + fieldStats.put(field, fieldMapper.stats(terms, reader.maxDoc())); } } else { throw new IllegalArgumentException("field [" + field + "] doesn't exist"); diff --git a/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java b/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java index f1d93568440..8b82e02f7a0 100644 --- a/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java +++ b/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java @@ -25,14 +25,9 @@ import org.apache.lucene.codecs.lucene50.Lucene50Codec; import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.lucene.Lucene; -import org.elasticsearch.index.mapper.FieldMappers; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.CompletionFieldMapper; -import org.elasticsearch.search.suggest.completion.Completion090PostingsFormat; -import org.elasticsearch.search.suggest.completion.Completion090PostingsFormat.CompletionLookupProvider; - -import java.util.HashMap; -import java.util.Map; /** * {@link PerFieldMappingPostingFormatCodec This postings format} is the default @@ -59,12 +54,12 @@ public class PerFieldMappingPostingFormatCodec extends Lucene50Codec { @Override public PostingsFormat getPostingsFormatForField(String field) { - final FieldMappers indexName = mapperService.indexName(field); + final FieldMapper indexName = mapperService.indexName(field); if (indexName == null) { logger.warn("no index mapper found for field: [{}] returning default postings format", field); - } else if (indexName.mapper() instanceof CompletionFieldMapper) { + } else if (indexName instanceof CompletionFieldMapper) { // CompletionFieldMapper needs a special postings format - final CompletionFieldMapper mapper = (CompletionFieldMapper) indexName.mapper(); + final CompletionFieldMapper mapper = (CompletionFieldMapper) indexName; final PostingsFormat defaultFormat = super.getPostingsFormatForField(field); return mapper.postingsFormat(defaultFormat); } diff --git a/src/main/java/org/elasticsearch/index/fieldvisitor/FieldsVisitor.java b/src/main/java/org/elasticsearch/index/fieldvisitor/FieldsVisitor.java index dda3d947712..60a6576380f 100644 --- a/src/main/java/org/elasticsearch/index/fieldvisitor/FieldsVisitor.java +++ b/src/main/java/org/elasticsearch/index/fieldvisitor/FieldsVisitor.java @@ -61,13 +61,13 @@ public abstract class FieldsVisitor extends StoredFieldVisitor { } // can't derive exact mapping type for (Map.Entry> entry : fields().entrySet()) { - FieldMappers fieldMappers = mapperService.indexName(entry.getKey()); + FieldMapper fieldMappers = mapperService.indexName(entry.getKey()); if (fieldMappers == null) { continue; } List fieldValues = entry.getValue(); for (int i = 0; i < fieldValues.size(); i++) { - fieldValues.set(i, fieldMappers.mapper().valueForSearch(fieldValues.get(i))); + fieldValues.set(i, fieldMappers.valueForSearch(fieldValues.get(i))); } } } diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 4c76b30d65e..37fb8830525 100755 --- a/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -447,14 +447,16 @@ public class MapperService extends AbstractIndexComponent { } /** - * Returns {@link FieldMappers} for all the {@link FieldMapper}s that are registered - * under the given indexName across all the different {@link DocumentMapper} types. + * Returns an {@link FieldMapper} which has the given index name. * - * @param indexName The indexName to return all the {@link FieldMappers} for across all {@link DocumentMapper}s. - * @return All the {@link FieldMappers} across all {@link DocumentMapper}s for the given indexName. + * If multiple types have fields with the same index name, the first is returned. */ - public FieldMappers indexName(String indexName) { - return fieldMappers.indexName(indexName); + public FieldMapper indexName(String indexName) { + FieldMappers mappers = fieldMappers.indexName(indexName); + if (mappers == null) { + return null; + } + return mappers.mapper(); } /** @@ -464,15 +466,12 @@ public class MapperService extends AbstractIndexComponent { * @param fullName The full name * @return All teh {@link FieldMappers} across all the {@link DocumentMapper}s for the given fullName. */ - public FieldMappers fullName(String fullName) { - return fieldMappers.fullName(fullName); - } - - /** - * Returns objects mappers based on the full path of the object. - */ - public ObjectMappers objectMapper(String path) { - return fullPathObjectMappers.get(path); + public FieldMapper fullName(String fullName) { + FieldMappers mappers = fieldMappers.fullName(fullName); + if (mappers == null) { + return null; + } + return mappers.mapper(); } /** @@ -510,7 +509,7 @@ public class MapperService extends AbstractIndexComponent { public SmartNameObjectMapper smartNameObjectMapper(String smartName, @Nullable String[] types) { if (types == null || types.length == 0 || types.length == 1 && types[0].equals("_all")) { - ObjectMappers mappers = objectMapper(smartName); + ObjectMappers mappers = fullPathObjectMappers.get(smartName); if (mappers != null) { return new SmartNameObjectMapper(mappers.mapper(), guessDocMapper(smartName)); } @@ -537,61 +536,17 @@ public class MapperService extends AbstractIndexComponent { return null; } - /** - * Same as {@link #smartNameFieldMappers(String)} but returns the first field mapper for it. Returns - * null if there is none. - */ public FieldMapper smartNameFieldMapper(String smartName) { - FieldMappers fieldMappers = smartNameFieldMappers(smartName); - if (fieldMappers != null) { - return fieldMappers.mapper(); - } - return null; - } - - public FieldMapper smartNameFieldMapper(String smartName, @Nullable String[] types) { - FieldMappers fieldMappers = smartNameFieldMappers(smartName, types); - if (fieldMappers != null) { - return fieldMappers.mapper(); - } - return null; - } - - public FieldMappers smartNameFieldMappers(String smartName, @Nullable String[] types) { - if (types == null || types.length == 0) { - return smartNameFieldMappers(smartName); - } - for (String type : types) { - DocumentMapper documentMapper = mappers.get(type); - // we found a mapper - if (documentMapper != null) { - // see if we find a field for it - FieldMappers mappers = documentMapper.mappers().smartName(smartName); - if (mappers != null) { - return mappers; - } - } - } - return null; - } - - /** - * Same as {@link #smartName(String)}, except it returns just the field mappers. - */ - public FieldMappers smartNameFieldMappers(String smartName) { - FieldMappers mappers = fullName(smartName); - if (mappers != null) { - return mappers; + FieldMapper mapper = fullName(smartName); + if (mapper != null) { + return mapper; } return indexName(smartName); } - public SmartNameFieldMappers smartName(String smartName, @Nullable String[] types) { + public FieldMapper smartNameFieldMapper(String smartName, @Nullable String[] types) { if (types == null || types.length == 0) { - return smartName(smartName); - } - if (types.length == 1 && types[0].equals("_all")) { - return smartName(smartName); + return smartNameFieldMapper(smartName); } for (String type : types) { DocumentMapper documentMapper = mappers.get(type); @@ -600,33 +555,13 @@ public class MapperService extends AbstractIndexComponent { // see if we find a field for it FieldMappers mappers = documentMapper.mappers().smartName(smartName); if (mappers != null) { - return new SmartNameFieldMappers(this, mappers, documentMapper, false); + return mappers.mapper(); } } } return null; } - /** - * Returns smart field mappers based on a smart name. A smart name is any of full name or index name. - *

- *

It will first try to find it based on the full name (with the dots if its a compound name). If - * it is not found, will try and find it based on the indexName (which can be controlled in the mapping). - *

- *

If nothing is found, returns null. - */ - public SmartNameFieldMappers smartName(String smartName) { - FieldMappers fieldMappers = fullName(smartName); - if (fieldMappers != null) { - return new SmartNameFieldMappers(this, fieldMappers, null, false); - } - fieldMappers = indexName(smartName); - if (fieldMappers != null) { - return new SmartNameFieldMappers(this, fieldMappers, null, false); - } - return null; - } - /** * Given a type (eg. long, string, ...), return an anonymous field mapper that can be used for search operations. */ @@ -671,7 +606,7 @@ public class MapperService extends AbstractIndexComponent { } else { do { String objectPath = fieldName.substring(0, indexOf); - ObjectMappers objectMappers = objectMapper(objectPath); + ObjectMappers objectMappers = fullPathObjectMappers.get(objectPath); if (objectMappers == null) { indexOf = objectPath.lastIndexOf('.'); continue; @@ -725,78 +660,6 @@ public class MapperService extends AbstractIndexComponent { } } - public static class SmartNameFieldMappers { - private final MapperService mapperService; - private final FieldMappers fieldMappers; - private final DocumentMapper docMapper; - - public SmartNameFieldMappers(MapperService mapperService, FieldMappers fieldMappers, @Nullable DocumentMapper docMapper, boolean explicitTypeInName) { - this.mapperService = mapperService; - this.fieldMappers = fieldMappers; - this.docMapper = docMapper; - } - - /** - * Has at least one mapper for the field. - */ - public boolean hasMapper() { - return !fieldMappers.isEmpty(); - } - - /** - * The first mapper for the smart named field. - */ - public FieldMapper mapper() { - return fieldMappers.mapper(); - } - - /** - * All the field mappers for the smart name field. - */ - public FieldMappers fieldMappers() { - return fieldMappers; - } - - /** - * If the smart name was a typed field, with a type that we resolved, will return - * true. - */ - public boolean hasDocMapper() { - return docMapper != null; - } - - /** - * If the smart name was a typed field, with a type that we resolved, will return - * the document mapper for it. - */ - public DocumentMapper docMapper() { - return docMapper; - } - - /** - * The best effort search analyzer associated with this field. - */ - public Analyzer searchAnalyzer() { - if (hasMapper()) { - Analyzer analyzer = mapper().searchAnalyzer(); - if (analyzer != null) { - return analyzer; - } - } - return mapperService.searchAnalyzer(); - } - - public Analyzer searchQuoteAnalyzer() { - if (hasMapper()) { - Analyzer analyzer = mapper().searchQuoteAnalyzer(); - if (analyzer != null) { - return analyzer; - } - } - return mapperService.searchQuoteAnalyzer(); - } - } - final class SmartIndexNameSearchAnalyzer extends DelegatingAnalyzerWrapper { private final Analyzer defaultAnalyzer; @@ -808,14 +671,9 @@ public class MapperService extends AbstractIndexComponent { @Override protected Analyzer getWrappedAnalyzer(String fieldName) { - FieldMappers mappers = fieldMappers.fullName(fieldName); - if (mappers != null && mappers.mapper() != null && mappers.mapper().searchAnalyzer() != null) { - return mappers.mapper().searchAnalyzer(); - } - - mappers = fieldMappers.indexName(fieldName); - if (mappers != null && mappers.mapper() != null && mappers.mapper().searchAnalyzer() != null) { - return mappers.mapper().searchAnalyzer(); + FieldMapper mapper = smartNameFieldMapper(fieldName); + if (mapper != null && mapper.searchAnalyzer() != null) { + return mapper.searchAnalyzer(); } return defaultAnalyzer; } @@ -832,14 +690,9 @@ public class MapperService extends AbstractIndexComponent { @Override protected Analyzer getWrappedAnalyzer(String fieldName) { - FieldMappers mappers = fieldMappers.fullName(fieldName); - if (mappers != null && mappers.mapper() != null && mappers.mapper().searchQuoteAnalyzer() != null) { - return mappers.mapper().searchQuoteAnalyzer(); - } - - mappers = fieldMappers.indexName(fieldName); - if (mappers != null && mappers.mapper() != null && mappers.mapper().searchQuoteAnalyzer() != null) { - return mappers.mapper().searchQuoteAnalyzer(); + FieldMapper mapper = smartNameFieldMapper(fieldName); + if (mapper != null && mapper.searchQuoteAnalyzer() != null) { + return mapper.searchQuoteAnalyzer(); } return defaultAnalyzer; } diff --git a/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java b/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java index 29945de5686..17c5c506ec7 100644 --- a/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java @@ -31,7 +31,6 @@ import org.apache.lucene.util.BytesRefBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import java.io.IOException; @@ -163,11 +162,9 @@ public class CommonTermsQueryParser implements QueryParser { if (value == null) { throw new QueryParsingException(parseContext, "No text specified for text query"); } - FieldMapper mapper = null; String field; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - mapper = smartNameFieldMappers.mapper(); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { field = mapper.names().indexName(); } else { field = fieldName; @@ -178,8 +175,8 @@ public class CommonTermsQueryParser implements QueryParser { if (mapper != null) { analyzer = mapper.searchAnalyzer(); } - if (analyzer == null && smartNameFieldMappers != null) { - analyzer = smartNameFieldMappers.searchAnalyzer(); + if (analyzer == null && mapper != null) { + analyzer = parseContext.getSearchAnalyzer(mapper); } if (analyzer == null) { analyzer = parseContext.mapperService().searchAnalyzer(); @@ -193,7 +190,7 @@ public class CommonTermsQueryParser implements QueryParser { ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency, disableCoords, mapper); commonsQuery.setBoost(boost); - Query query = parseQueryString(commonsQuery, value.toString(), field, parseContext, analyzer, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch, smartNameFieldMappers); + Query query = parseQueryString(commonsQuery, value.toString(), field, parseContext, analyzer, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch); if (queryName != null) { parseContext.addNamedQuery(queryName, query); } @@ -202,7 +199,7 @@ public class CommonTermsQueryParser implements QueryParser { private final Query parseQueryString(ExtendedCommonTermsQuery query, String queryString, String field, QueryParseContext parseContext, - Analyzer analyzer, String lowFreqMinimumShouldMatch, String highFreqMinimumShouldMatch, MapperService.SmartNameFieldMappers smartNameFieldMappers) throws IOException { + Analyzer analyzer, String lowFreqMinimumShouldMatch, String highFreqMinimumShouldMatch) throws IOException { // Logic similar to QueryParser#getFieldQuery int count = 0; try (TokenStream source = analyzer.tokenStream(field, queryString.toString())) { diff --git a/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java b/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java index b77fa8f1da6..3d049d98e7c 100644 --- a/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/ExistsQueryParser.java @@ -27,7 +27,7 @@ import org.apache.lucene.search.TermRangeQuery; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.FieldMappers; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper; @@ -81,8 +81,7 @@ public class ExistsQueryParser implements QueryParser { } public static Query newFilter(QueryParseContext parseContext, String fieldPattern, String queryName) { - final FieldMappers fieldNamesMappers = parseContext.mapperService().fullName(FieldNamesFieldMapper.NAME); - final FieldNamesFieldMapper fieldNamesMapper = (FieldNamesFieldMapper)fieldNamesMappers.mapper(); + final FieldNamesFieldMapper fieldNamesMapper = (FieldNamesFieldMapper)parseContext.mapperService().fullName(FieldNamesFieldMapper.NAME); MapperService.SmartNameObjectMapper smartNameObjectMapper = parseContext.smartObjectMapper(fieldPattern); if (smartNameObjectMapper != null && smartNameObjectMapper.hasMapper()) { @@ -98,20 +97,20 @@ public class ExistsQueryParser implements QueryParser { BooleanQuery boolFilter = new BooleanQuery(); for (String field : fields) { - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(field); + FieldMapper mapper = parseContext.fieldMapper(field); Query filter = null; if (fieldNamesMapper!= null && fieldNamesMapper.enabled()) { final String f; - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - f = smartNameFieldMappers.mapper().names().indexName(); + if (mapper != null) { + f = mapper.names().indexName(); } else { f = field; } filter = fieldNamesMapper.termQuery(f, parseContext); } // if _field_names are not indexed, we need to go the slow way - if (filter == null && smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - filter = smartNameFieldMappers.mapper().rangeQuery(null, null, true, true, parseContext); + if (filter == null && mapper != null) { + filter = mapper.rangeQuery(null, null, true, true, parseContext); } if (filter == null) { filter = new TermRangeQuery(field, null, null, true, true); diff --git a/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java b/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java index de6fdd00cde..ae87e9116c7 100644 --- a/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/FuzzyQueryParser.java @@ -22,13 +22,12 @@ package org.elasticsearch.index.query; import org.apache.lucene.index.Term; import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.MultiTermQuery; -import org.apache.lucene.search.MultiTermQuery.RewriteMethod; import org.apache.lucene.search.Query; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; @@ -115,11 +114,9 @@ public class FuzzyQueryParser implements QueryParser { } Query query = null; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null) { - if (smartNameFieldMappers.hasMapper()) { - query = smartNameFieldMappers.mapper().fuzzyQuery(value, fuzziness, prefixLength, maxExpansions, transpositions); - } + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + query = mapper.fuzzyQuery(value, fuzziness, prefixLength, maxExpansions, transpositions); } if (query == null) { query = new FuzzyQuery(new Term(fieldName, value), fuzziness.asDistance(value), prefixLength, maxExpansions, transpositions); diff --git a/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java b/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java index 7b60cde4c97..d79d75537f8 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoBoundingBoxQueryParser.java @@ -27,7 +27,6 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.search.geo.InMemoryGeoBoundingBoxQuery; import org.elasticsearch.index.search.geo.IndexedGeoBoundingBoxQuery; @@ -161,11 +160,10 @@ public class GeoBoundingBoxQueryParser implements QueryParser { } } - MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName); - if (smartMappers == null || !smartMappers.hasMapper()) { + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper == null) { throw new QueryParsingException(parseContext, "failed to find geo_point field [" + fieldName + "]"); } - FieldMapper mapper = smartMappers.mapper(); if (!(mapper instanceof GeoPointFieldMapper)) { throw new QueryParsingException(parseContext, "field [" + fieldName + "] is not a geo_point field"); } diff --git a/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java b/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java index 2a74a429715..ceaf422db21 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java @@ -29,7 +29,6 @@ import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery; @@ -148,11 +147,10 @@ public class GeoDistanceQueryParser implements QueryParser { GeoUtils.normalizePoint(point, normalizeLat, normalizeLon); } - MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName); - if (smartMappers == null || !smartMappers.hasMapper()) { + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper == null) { throw new QueryParsingException(parseContext, "failed to find geo_point field [" + fieldName + "]"); } - FieldMapper mapper = smartMappers.mapper(); if (!(mapper instanceof GeoPointFieldMapper)) { throw new QueryParsingException(parseContext, "field [" + fieldName + "] is not a geo_point field"); } diff --git a/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java b/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java index 14cf5667b22..5584ee35e44 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoDistanceRangeQueryParser.java @@ -29,7 +29,6 @@ import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.search.geo.GeoDistanceRangeQuery; @@ -188,11 +187,10 @@ public class GeoDistanceRangeQueryParser implements QueryParser { GeoUtils.normalizePoint(point, normalizeLat, normalizeLon); } - MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName); - if (smartMappers == null || !smartMappers.hasMapper()) { + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper == null) { throw new QueryParsingException(parseContext, "failed to find geo_point field [" + fieldName + "]"); } - FieldMapper mapper = smartMappers.mapper(); if (!(mapper instanceof GeoPointFieldMapper)) { throw new QueryParsingException(parseContext, "field [" + fieldName + "] is not a geo_point field"); } diff --git a/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java b/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java index 2f80cb54a9f..4b10361775f 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoPolygonQueryParser.java @@ -29,7 +29,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; import org.elasticsearch.index.search.geo.GeoPolygonQuery; @@ -137,11 +136,10 @@ public class GeoPolygonQueryParser implements QueryParser { } } - MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName); - if (smartMappers == null || !smartMappers.hasMapper()) { + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper == null) { throw new QueryParsingException(parseContext, "failed to find geo_point field [" + fieldName + "]"); } - FieldMapper mapper = smartMappers.mapper(); if (!(mapper instanceof GeoPointFieldMapper)) { throw new QueryParsingException(parseContext, "field [" + fieldName + "] is not a geo_point field"); } diff --git a/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java b/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java index 83e35e13d5e..3a63ae68295 100644 --- a/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.geo.builders.ShapeBuilder; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper; import org.elasticsearch.index.search.shape.ShapeFetchService; import org.elasticsearch.search.internal.SearchContext; @@ -139,12 +138,11 @@ public class GeoShapeQueryParser implements QueryParser { throw new QueryParsingException(parseContext, "No Shape Relation defined"); } - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers == null || !smartNameFieldMappers.hasMapper()) { + FieldMapper fieldMapper = parseContext.fieldMapper(fieldName); + if (fieldMapper == null) { throw new QueryParsingException(parseContext, "Failed to find geo_shape field [" + fieldName + "]"); } - FieldMapper fieldMapper = smartNameFieldMappers.mapper(); // TODO: This isn't the nicest way to check this if (!(fieldMapper instanceof GeoShapeFieldMapper)) { throw new QueryParsingException(parseContext, "Field [" + fieldName + "] is not a geo_shape"); diff --git a/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java b/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java index 2e0089ded4f..08b38453dc6 100644 --- a/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java +++ b/src/main/java/org/elasticsearch/index/query/GeohashCellQuery.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; @@ -237,12 +236,11 @@ public class GeohashCellQuery { throw new QueryParsingException(parseContext, "no geohash value provided to geohash_cell filter"); } - MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName); - if (smartMappers == null || !smartMappers.hasMapper()) { + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper == null) { throw new QueryParsingException(parseContext, "failed to find geo_point field [" + fieldName + "]"); } - FieldMapper mapper = smartMappers.mapper(); if (!(mapper instanceof GeoPointFieldMapper)) { throw new QueryParsingException(parseContext, "field [" + fieldName + "] is not a geo_point field"); } diff --git a/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java b/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java index d33d686fb0b..47d5baac85e 100644 --- a/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java @@ -29,7 +29,7 @@ import org.apache.lucene.search.TermRangeQuery; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.FieldMappers; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper; @@ -95,8 +95,7 @@ public class MissingQueryParser implements QueryParser { throw new QueryParsingException(parseContext, "missing must have either existence, or null_value, or both set to true"); } - final FieldMappers fieldNamesMappers = parseContext.mapperService().fullName(FieldNamesFieldMapper.NAME); - final FieldNamesFieldMapper fieldNamesMapper = (FieldNamesFieldMapper)fieldNamesMappers.mapper(); + final FieldNamesFieldMapper fieldNamesMapper = (FieldNamesFieldMapper)parseContext.mapperService().fullName(FieldNamesFieldMapper.NAME); MapperService.SmartNameObjectMapper smartNameObjectMapper = parseContext.smartObjectMapper(fieldPattern); if (smartNameObjectMapper != null && smartNameObjectMapper.hasMapper()) { // automatic make the object mapper pattern @@ -118,20 +117,20 @@ public class MissingQueryParser implements QueryParser { if (existence) { BooleanQuery boolFilter = new BooleanQuery(); for (String field : fields) { - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(field); + FieldMapper mapper = parseContext.fieldMapper(field); Query filter = null; if (fieldNamesMapper != null && fieldNamesMapper.enabled()) { final String f; - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - f = smartNameFieldMappers.mapper().names().indexName(); + if (mapper != null) { + f = mapper.names().indexName(); } else { f = field; } filter = fieldNamesMapper.termQuery(f, parseContext); } // if _field_names are not indexed, we need to go the slow way - if (filter == null && smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - filter = smartNameFieldMappers.mapper().rangeQuery(null, null, true, true, parseContext); + if (filter == null && mapper != null) { + filter = mapper.rangeQuery(null, null, true, true, parseContext); } if (filter == null) { filter = new TermRangeQuery(field, null, null, true, true); @@ -145,9 +144,9 @@ public class MissingQueryParser implements QueryParser { if (nullValue) { for (String field : fields) { - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(field); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - nullFilter = smartNameFieldMappers.mapper().nullValueFilter(); + FieldMapper mapper = parseContext.fieldMapper(field); + if (mapper != null) { + nullFilter = mapper.nullValueFilter(); } } } diff --git a/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java b/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java index c1d3792e7f6..fe1c99e421a 100644 --- a/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryParser.java @@ -37,6 +37,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.analysis.Analysis; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.search.morelikethis.MoreLikeThisFetchService; import org.elasticsearch.search.internal.SearchContext; @@ -164,7 +165,9 @@ public class MoreLikeThisQueryParser implements QueryParser { } else if ("fields".equals(currentFieldName)) { moreLikeFields = Lists.newLinkedList(); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { - moreLikeFields.add(parseContext.indexName(parser.text())); + String field = parser.text(); + FieldMapper mapper = parseContext.fieldMapper(field); + moreLikeFields.add(mapper == null ? field : mapper.names().indexName()); } } else if (Fields.DOCUMENT_IDS.match(currentFieldName, parseContext.parseFlags())) { while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { diff --git a/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java b/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java index 893ec14dad3..63c91ba8861 100644 --- a/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/PrefixQueryParser.java @@ -26,7 +26,7 @@ import org.apache.lucene.search.Query; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; @@ -100,9 +100,9 @@ public class PrefixQueryParser implements QueryParser { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewriteMethod, null); Query query = null; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - query = smartNameFieldMappers.mapper().prefixQuery(value, method, parseContext); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + query = mapper.prefixQuery(value, method, parseContext); } if (query == null) { PrefixQuery prefixQuery = new PrefixQuery(new Term(fieldName, BytesRefs.toBytesRef(value))); diff --git a/src/main/java/org/elasticsearch/index/query/QueryParseContext.java b/src/main/java/org/elasticsearch/index/query/QueryParseContext.java index 4d6d1378835..fdc63bb81c5 100644 --- a/src/main/java/org/elasticsearch/index/query/QueryParseContext.java +++ b/src/main/java/org/elasticsearch/index/query/QueryParseContext.java @@ -22,6 +22,7 @@ package org.elasticsearch.index.query; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.queryparser.classic.MapperQueryParser; import org.apache.lucene.queryparser.classic.QueryParserSettings; import org.apache.lucene.search.Filter; @@ -282,34 +283,38 @@ public class QueryParseContext { } } - public FieldMapper fieldMapper(String name) { - FieldMappers fieldMappers = indexQueryParser.mapperService.smartNameFieldMappers(name, getTypes()); - if (fieldMappers == null) { - return null; - } - return fieldMappers.mapper(); - } - - public String indexName(String name) { - FieldMapper smartMapper = fieldMapper(name); - if (smartMapper == null) { - return name; - } - return smartMapper.names().indexName(); - } - public List simpleMatchToIndexNames(String pattern) { return indexQueryParser.mapperService.simpleMatchToIndexNames(pattern, getTypes()); } - public MapperService.SmartNameFieldMappers smartFieldMappers(String name) { - return failIfFieldMappingNotFound(name, indexQueryParser.mapperService.smartName(name, getTypes())); + public FieldMapper fieldMapper(String name) { + return failIfFieldMappingNotFound(name, indexQueryParser.mapperService.smartNameFieldMapper(name, getTypes())); } public MapperService.SmartNameObjectMapper smartObjectMapper(String name) { return indexQueryParser.mapperService.smartNameObjectMapper(name, getTypes()); } + /** Gets the search analyzer for the given field, or the default if there is none present for the field + * TODO: remove this by moving defaults into mappers themselves + */ + public Analyzer getSearchAnalyzer(FieldMapper mapper) { + if (mapper.searchAnalyzer() != null) { + return mapper.searchAnalyzer(); + } + return mapperService().searchAnalyzer(); + } + + /** Gets the search quote nalyzer for the given field, or the default if there is none present for the field + * TODO: remove this by moving defaults into mappers themselves + */ + public Analyzer getSearchQuoteAnalyzer(FieldMapper mapper) { + if (mapper.searchQuoteAnalyzer() != null) { + return mapper.searchQuoteAnalyzer(); + } + return mapperService().searchQuoteAnalyzer(); + } + public void setAllowUnmappedFields(boolean allowUnmappedFields) { this.allowUnmappedFields = allowUnmappedFields; } @@ -318,7 +323,7 @@ public class QueryParseContext { this.mapUnmappedFieldAsString = mapUnmappedFieldAsString; } - private MapperService.SmartNameFieldMappers failIfFieldMappingNotFound(String name, MapperService.SmartNameFieldMappers fieldMapping) { + private FieldMapper failIfFieldMappingNotFound(String name, FieldMapper fieldMapping) { if (allowUnmappedFields) { return fieldMapping; } else if (mapUnmappedFieldAsString){ @@ -326,7 +331,7 @@ public class QueryParseContext { // it would be better to pass the real index settings, but they are not easily accessible from here... Settings settings = ImmutableSettings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexQueryParser.getIndexCreatedVersion()).build(); StringFieldMapper stringFieldMapper = builder.build(new Mapper.BuilderContext(settings, new ContentPath(1))); - return new MapperService.SmartNameFieldMappers(mapperService(), new FieldMappers(stringFieldMapper), null, false); + return stringFieldMapper; } else { Version indexCreatedVersion = indexQueryParser.getIndexCreatedVersion(); if (fieldMapping == null && indexCreatedVersion.onOrAfter(Version.V_1_4_0_Beta1)) { diff --git a/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java b/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java index 4c51b2eb4d2..e86ffebde31 100644 --- a/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/RangeQueryParser.java @@ -28,7 +28,6 @@ import org.elasticsearch.common.joda.Joda; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.joda.time.DateTimeZone; @@ -121,26 +120,22 @@ public class RangeQueryParser implements QueryParser { } Query query = null; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null) { - if (smartNameFieldMappers.hasMapper()) { - FieldMapper mapper = smartNameFieldMappers.mapper(); - if (mapper instanceof DateFieldMapper) { - if ((from instanceof Number || to instanceof Number) && timeZone != null) { - throw new QueryParsingException(parseContext, - "[range] time_zone when using ms since epoch format as it's UTC based can not be applied to [" + fieldName - + "]"); - } - query = ((DateFieldMapper) mapper).rangeQuery(from, to, includeLower, includeUpper, timeZone, forcedDateParser, parseContext); - } else { - if (timeZone != null) { - throw new QueryParsingException(parseContext, "[range] time_zone can not be applied to non date field [" - + fieldName + "]"); - } - //LUCENE 4 UPGRADE Mapper#rangeQuery should use bytesref as well? - query = mapper.rangeQuery(from, to, includeLower, includeUpper, parseContext); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + if (mapper instanceof DateFieldMapper) { + if ((from instanceof Number || to instanceof Number) && timeZone != null) { + throw new QueryParsingException(parseContext, + "[range] time_zone when using ms since epoch format as it's UTC based can not be applied to [" + fieldName + + "]"); } - + query = ((DateFieldMapper) mapper).rangeQuery(from, to, includeLower, includeUpper, timeZone, forcedDateParser, parseContext); + } else { + if (timeZone != null) { + throw new QueryParsingException(parseContext, "[range] time_zone can not be applied to non date field [" + + fieldName + "]"); + } + //LUCENE 4 UPGRADE Mapper#rangeQuery should use bytesref as well? + query = mapper.rangeQuery(from, to, includeLower, includeUpper, parseContext); } } if (query == null) { diff --git a/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java b/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java index 6a0b9eb4249..f154230b563 100644 --- a/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/RegexpQueryParser.java @@ -24,11 +24,10 @@ import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.RegexpQuery; import org.apache.lucene.util.automaton.Operations; -import org.apache.lucene.util.automaton.RegExp; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; @@ -109,9 +108,9 @@ public class RegexpQueryParser implements QueryParser { MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewriteMethod, null); Query query = null; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - query = smartNameFieldMappers.mapper().regexpQuery(value, flagsValue, maxDeterminizedStates, method, parseContext); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + query = mapper.regexpQuery(value, flagsValue, maxDeterminizedStates, method, parseContext); } if (query == null) { RegexpQuery regexpQuery = new RegexpQuery(new Term(fieldName, BytesRefs.toBytesRef(value)), flagsValue, maxDeterminizedStates); diff --git a/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java b/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java index 446dbc95b57..d48c5b7163f 100644 --- a/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java +++ b/src/main/java/org/elasticsearch/index/query/SimpleQueryStringParser.java @@ -30,7 +30,7 @@ import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.LocaleUtils; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import java.io.IOException; import java.util.Collections; @@ -130,9 +130,9 @@ public class SimpleQueryStringParser implements QueryParser { fieldsAndWeights.put(fieldName, fBoost); } } else { - MapperService.SmartNameFieldMappers mappers = parseContext.smartFieldMappers(fField); - if (mappers != null && mappers.hasMapper()) { - fieldsAndWeights.put(mappers.mapper().names().indexName(), fBoost); + FieldMapper mapper = parseContext.fieldMapper(fField); + if (mapper != null) { + fieldsAndWeights.put(mapper.names().indexName(), fBoost); } else { fieldsAndWeights.put(fField, fBoost); } diff --git a/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java b/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java index 535b626306a..b1b3cbf5fbf 100644 --- a/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/SpanTermQueryParser.java @@ -26,7 +26,7 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import java.io.IOException; @@ -93,12 +93,10 @@ public class SpanTermQueryParser implements QueryParser { } BytesRef valueBytes = null; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null) { - if (smartNameFieldMappers.hasMapper()) { - fieldName = smartNameFieldMappers.mapper().names().indexName(); - valueBytes = smartNameFieldMappers.mapper().indexedValueForSearch(value); - } + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + fieldName = mapper.names().indexName(); + valueBytes = mapper.indexedValueForSearch(value); } if (valueBytes == null) { valueBytes = new BytesRef(value); diff --git a/src/main/java/org/elasticsearch/index/query/TermQueryParser.java b/src/main/java/org/elasticsearch/index/query/TermQueryParser.java index a760a041b1c..5e6babdbaeb 100644 --- a/src/main/java/org/elasticsearch/index/query/TermQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermQueryParser.java @@ -25,7 +25,7 @@ import org.apache.lucene.search.TermQuery; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import java.io.IOException; @@ -97,9 +97,9 @@ public class TermQueryParser implements QueryParser { } Query query = null; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - query = smartNameFieldMappers.mapper().termQuery(value, parseContext); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + query = mapper.termQuery(value, parseContext); } if (query == null) { query = new TermQuery(new Term(fieldName, BytesRefs.toBytesRef(value))); diff --git a/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java b/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java index d663885d5b6..d3c44fa2303 100644 --- a/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java @@ -37,7 +37,6 @@ import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.cache.filter.terms.TermsLookup; import org.elasticsearch.search.internal.SearchContext; @@ -74,7 +73,6 @@ public class TermsQueryParser implements QueryParser { public Query parse(QueryParseContext parseContext) throws IOException, QueryParsingException { XContentParser parser = parseContext.parser(); - MapperService.SmartNameFieldMappers smartNameFieldMappers; String queryName = null; String currentFieldName = null; @@ -160,13 +158,9 @@ public class TermsQueryParser implements QueryParser { throw new QueryParsingException(parseContext, "terms query requires a field name, followed by array of terms"); } - FieldMapper fieldMapper = null; - smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null) { - if (smartNameFieldMappers.hasMapper()) { - fieldMapper = smartNameFieldMappers.mapper(); - fieldName = fieldMapper.names().indexName(); - } + FieldMapper fieldMapper = parseContext.fieldMapper(fieldName); + if (fieldMapper != null) { + fieldName = fieldMapper.names().indexName(); } if (lookupId != null) { diff --git a/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java b/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java index a661c185878..36ca202173e 100644 --- a/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/WildcardQueryParser.java @@ -25,7 +25,7 @@ import org.apache.lucene.search.WildcardQuery; import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.query.support.QueryParsers; import java.io.IOException; @@ -93,10 +93,10 @@ public class WildcardQueryParser implements QueryParser { } BytesRef valueBytes; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - fieldName = smartNameFieldMappers.mapper().names().indexName(); - valueBytes = smartNameFieldMappers.mapper().indexedValueForSearch(value); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { + fieldName = mapper.names().indexName(); + valueBytes = mapper.indexedValueForSearch(value); } else { valueBytes = new BytesRef(value); } diff --git a/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java b/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java index 001bdf05854..70c51deb03d 100644 --- a/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java +++ b/src/main/java/org/elasticsearch/index/query/functionscore/DecayFunctionParser.java @@ -40,7 +40,6 @@ import org.elasticsearch.index.fielddata.MultiGeoPointValues; import org.elasticsearch.index.fielddata.NumericDoubleValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.mapper.core.NumberFieldMapper; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; @@ -152,12 +151,11 @@ public abstract class DecayFunctionParser implements ScoreFunctionParser { // now, the field must exist, else we cannot read the value for // the doc later - MapperService.SmartNameFieldMappers smartMappers = parseContext.smartFieldMappers(fieldName); - if (smartMappers == null || !smartMappers.hasMapper()) { + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper == null) { throw new QueryParsingException(parseContext, "Unknown field [" + fieldName + "]"); } - FieldMapper mapper = smartMappers.fieldMappers().mapper(); // dates and time need special handling parser.nextToken(); if (mapper instanceof DateFieldMapper) { diff --git a/src/main/java/org/elasticsearch/index/search/MatchQuery.java b/src/main/java/org/elasticsearch/index/search/MatchQuery.java index 784f4ce18e3..5f08c6f4703 100644 --- a/src/main/java/org/elasticsearch/index/search/MatchQuery.java +++ b/src/main/java/org/elasticsearch/index/search/MatchQuery.java @@ -30,7 +30,6 @@ import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.query.support.QueryParsers; @@ -139,33 +138,25 @@ public class MatchQuery { return false; } - protected Analyzer getAnalyzer(FieldMapper mapper, MapperService.SmartNameFieldMappers smartNameFieldMappers) { - Analyzer analyzer = null; + protected Analyzer getAnalyzer(FieldMapper mapper) { if (this.analyzer == null) { if (mapper != null) { - analyzer = mapper.searchAnalyzer(); - } - if (analyzer == null && smartNameFieldMappers != null) { - analyzer = smartNameFieldMappers.searchAnalyzer(); - } - if (analyzer == null) { - analyzer = parseContext.mapperService().searchAnalyzer(); + return parseContext.getSearchAnalyzer(mapper); } + return parseContext.mapperService().searchAnalyzer(); } else { - analyzer = parseContext.mapperService().analysisService().analyzer(this.analyzer); + Analyzer analyzer = parseContext.mapperService().analysisService().analyzer(this.analyzer); if (analyzer == null) { throw new IllegalArgumentException("No analyzer found for [" + this.analyzer + "]"); } + return analyzer; } - return analyzer; } public Query parse(Type type, String fieldName, Object value) throws IOException { - FieldMapper mapper = null; final String field; - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - mapper = smartNameFieldMappers.mapper(); + FieldMapper mapper = parseContext.fieldMapper(fieldName); + if (mapper != null) { field = mapper.names().indexName(); } else { field = fieldName; @@ -182,7 +173,8 @@ public class MatchQuery { } } - Analyzer analyzer = getAnalyzer(mapper, smartNameFieldMappers); + Analyzer analyzer = getAnalyzer(mapper); + assert analyzer != null; MatchQueryBuilder builder = new MatchQueryBuilder(analyzer, mapper); builder.setEnablePositionIncrements(this.enablePositionIncrements); diff --git a/src/main/java/org/elasticsearch/index/search/MultiMatchQuery.java b/src/main/java/org/elasticsearch/index/search/MultiMatchQuery.java index f9a1e76034d..ea9666f0746 100644 --- a/src/main/java/org/elasticsearch/index/search/MultiMatchQuery.java +++ b/src/main/java/org/elasticsearch/index/search/MultiMatchQuery.java @@ -30,7 +30,6 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.MultiMatchQueryBuilder; import org.elasticsearch.index.query.QueryParseContext; @@ -163,16 +162,16 @@ public class MultiMatchQuery extends MatchQuery { List> missing = new ArrayList<>(); for (Map.Entry entry : fieldNames.entrySet()) { String name = entry.getKey(); - MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(name); - if (smartNameFieldMappers != null && smartNameFieldMappers.hasMapper()) { - Analyzer actualAnalyzer = getAnalyzer(smartNameFieldMappers.mapper(), smartNameFieldMappers); - name = smartNameFieldMappers.mapper().names().indexName(); + FieldMapper mapper = parseContext.fieldMapper(name); + if (mapper != null) { + Analyzer actualAnalyzer = getAnalyzer(mapper); + name = mapper.names().indexName(); if (!groups.containsKey(actualAnalyzer)) { groups.put(actualAnalyzer, new ArrayList()); } Float boost = entry.getValue(); boost = boost == null ? Float.valueOf(1.0f) : boost; - groups.get(actualAnalyzer).add(new FieldAndMapper(name, smartNameFieldMappers.mapper(), boost)); + groups.get(actualAnalyzer).add(new FieldAndMapper(name, mapper, boost)); } else { missing.add(new Tuple(name, entry.getValue())); } diff --git a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java index 9adbeb88280..a034219b92a 100644 --- a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java +++ b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java @@ -41,6 +41,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.fieldvisitor.UidAndRoutingFieldsVisitor; +import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.Uid; @@ -170,15 +171,11 @@ public class IndicesTTLService extends AbstractLifecycleComponent(); } - fieldNames.add(x.mapper().names().indexName()); + fieldNames.add(mapper.names().indexName()); } else { if (extractFieldNames == null) { extractFieldNames = newArrayList(); diff --git a/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java b/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java index e15a778767d..8211d60bc13 100644 --- a/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java @@ -712,16 +712,6 @@ public class DefaultSearchContext extends SearchContext { return scanContext; } - @Override - public MapperService.SmartNameFieldMappers smartFieldMappers(String name) { - return mapperService().smartName(name, request.types()); - } - - @Override - public FieldMappers smartNameFieldMappers(String name) { - return mapperService().smartNameFieldMappers(name, request.types()); - } - @Override public FieldMapper smartNameFieldMapper(String name) { return mapperService().smartNameFieldMapper(name, request.types()); diff --git a/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java b/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java index 2ebb7f0e337..0c73f1d048f 100644 --- a/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java @@ -531,16 +531,6 @@ public abstract class FilteredSearchContext extends SearchContext { return in.scanContext(); } - @Override - public MapperService.SmartNameFieldMappers smartFieldMappers(String name) { - return in.smartFieldMappers(name); - } - - @Override - public FieldMappers smartNameFieldMappers(String name) { - return in.smartNameFieldMappers(name); - } - @Override public FieldMapper smartNameFieldMapper(String name) { return in.smartNameFieldMapper(name); diff --git a/src/main/java/org/elasticsearch/search/internal/SearchContext.java b/src/main/java/org/elasticsearch/search/internal/SearchContext.java index 099ed8cff09..fe6dcd8c67e 100644 --- a/src/main/java/org/elasticsearch/search/internal/SearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/SearchContext.java @@ -343,10 +343,6 @@ public abstract class SearchContext implements Releasable, HasContextAndHeaders public abstract ScanContext scanContext(); - public abstract MapperService.SmartNameFieldMappers smartFieldMappers(String name); - - public abstract FieldMappers smartNameFieldMappers(String name); - public abstract FieldMapper smartNameFieldMapper(String name); /** diff --git a/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java index 19994257d0d..ba93e196177 100644 --- a/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/DynamicMappingTests.java @@ -166,8 +166,8 @@ public class DynamicMappingTests extends ElasticsearchSingleNodeTest { public void testDynamicMappingOnEmptyString() throws Exception { IndexService service = createIndex("test"); client().prepareIndex("test", "type").setSource("empty_field", "").get(); - FieldMappers mappers = service.mapperService().fullName("empty_field"); - assertTrue(mappers != null && mappers.isEmpty() == false); + FieldMapper mapper = service.mapperService().fullName("empty_field"); + assertNotNull(mapper); } public void testTypeNotCreatedOnIndexFailure() throws IOException, InterruptedException { diff --git a/src/test/java/org/elasticsearch/test/TestSearchContext.java b/src/test/java/org/elasticsearch/test/TestSearchContext.java index 42847de819b..321f01a3c25 100644 --- a/src/test/java/org/elasticsearch/test/TestSearchContext.java +++ b/src/test/java/org/elasticsearch/test/TestSearchContext.java @@ -551,16 +551,6 @@ public class TestSearchContext extends SearchContext { return null; } - @Override - public MapperService.SmartNameFieldMappers smartFieldMappers(String name) { - return null; - } - - @Override - public FieldMappers smartNameFieldMappers(String name) { - return null; - } - @Override public FieldMapper smartNameFieldMapper(String name) { if (mapperService() != null) {