diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java index 865f52c8671b7..c398fde04a2f6 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryShardContext.java @@ -75,8 +75,8 @@ public class QueryShardContext extends QueryRewriteContext { private static final DeprecationLogger deprecationLogger = new DeprecationLogger( LogManager.getLogger(QueryShardContext.class)); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using the _type field " + - "in queries is deprecated, prefer to filter on a field instead."; + public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using the _type field " + + "in queries and aggregations is deprecated, prefer to use a field instead."; private final ScriptService scriptService; private final IndexSettings indexSettings; diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfigTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfigTests.java index b213ca785e234..ad41e97364655 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfigTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/support/ValuesSourceConfigTests.java @@ -27,6 +27,7 @@ import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.Engine.Searcher; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; +import org.elasticsearch.index.mapper.TypeFieldMapper; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.test.ESSingleNodeTestCase; @@ -259,6 +260,16 @@ public void testUnmappedBoolean() throws Exception { } } + public void testTypeFieldDeprecation() { + IndexService indexService = createIndex("index", Settings.EMPTY, "type"); + try (Searcher searcher = indexService.getShard(0).acquireSearcher("test")) { + QueryShardContext context = indexService.newQueryShardContext(0, searcher.reader(), () -> 42L, null); + + ValuesSourceConfig config = ValuesSourceConfig.resolve( + context, null, TypeFieldMapper.NAME, null, null, null, null); + assertWarnings(QueryShardContext.TYPES_DEPRECATION_MESSAGE); + } + } public void testFieldAlias() throws Exception { IndexService indexService = createIndex("index", Settings.EMPTY, "type",