diff --git a/src/main/java/org/elasticsearch/percolator/PercolateContext.java b/src/main/java/org/elasticsearch/percolator/PercolateContext.java index 7fc3f76fb2a..b0eb104bf8c 100644 --- a/src/main/java/org/elasticsearch/percolator/PercolateContext.java +++ b/src/main/java/org/elasticsearch/percolator/PercolateContext.java @@ -663,6 +663,11 @@ public class PercolateContext extends SearchContext { return mapperService().smartNameFieldMapper(name, types); } + @Override + public FieldMapper smartNameFieldMapperFromAnyType(String name) { + return mapperService().smartNameFieldMapper(name); + } + @Override public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) { throw new UnsupportedOperationException(); diff --git a/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java b/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java index 6c8f31cff6e..221b6b33489 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java @@ -152,7 +152,7 @@ public class ValuesSourceParser { return config; } - FieldMapper mapper = context.mapperService().smartNameFieldMapper(input.field); + FieldMapper mapper = context.smartNameFieldMapperFromAnyType(input.field); if (mapper == null) { Class valuesSourceType = valueType != null ? (Class) valueType.getValuesSourceType() : this.valuesSourceType; ValuesSourceConfig config = new ValuesSourceConfig<>(valuesSourceType); diff --git a/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java b/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java index faf3be50551..af618153940 100644 --- a/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java @@ -671,18 +671,27 @@ 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()); } + @Override + public FieldMapper smartNameFieldMapperFromAnyType(String name) { + return mapperService().smartNameFieldMapper(name); + } + + @Override public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) { return mapperService().smartNameObjectMapper(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 cd0a7c93954..ce5dafc8b8f 100644 --- a/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java @@ -548,6 +548,11 @@ public abstract class FilteredSearchContext extends SearchContext { return in.smartNameFieldMapper(name); } + @Override + public FieldMapper smartNameFieldMapperFromAnyType(String name) { + return in.smartNameFieldMapperFromAnyType(name); + } + @Override public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) { return in.smartNameObjectMapper(name); diff --git a/src/main/java/org/elasticsearch/search/internal/SearchContext.java b/src/main/java/org/elasticsearch/search/internal/SearchContext.java index 7a7b53e6a92..5c99bd3918e 100644 --- a/src/main/java/org/elasticsearch/search/internal/SearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/SearchContext.java @@ -349,6 +349,11 @@ public abstract class SearchContext implements Releasable { public abstract FieldMapper smartNameFieldMapper(String name); + /** + * Looks up the given field, but does not restrict to fields in the types set on this context. + */ + public abstract FieldMapper smartNameFieldMapperFromAnyType(String name); + public abstract MapperService.SmartNameObjectMapper smartNameObjectMapper(String name); public abstract Counter timeEstimateCounter(); diff --git a/src/test/java/org/elasticsearch/test/TestSearchContext.java b/src/test/java/org/elasticsearch/test/TestSearchContext.java index 3bab21cdaa4..4cfa041266a 100644 --- a/src/test/java/org/elasticsearch/test/TestSearchContext.java +++ b/src/test/java/org/elasticsearch/test/TestSearchContext.java @@ -570,9 +570,20 @@ public class TestSearchContext extends SearchContext { return null; } + @Override + public FieldMapper smartNameFieldMapperFromAnyType(String name) { + if (mapperService() != null) { + return mapperService().smartNameFieldMapper(name); + } + return null; + } + @Override public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) { - return mapperService().smartNameObjectMapper(name, types); + if (mapperService() != null) { + return mapperService().smartNameObjectMapper(name, types); + } + return null; } @Override