Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate use of the _type field in aggregations. #37131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<ValuesSource.Bytes> 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",
Expand Down