-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Deprecate uses of _type as a field name in queries #36503
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
Changes from all commits
0947bad
88d4e9c
9e9cab1
cad2ed2
29fd27d
668dfbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,9 +90,11 @@ public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext c | |
} | ||
} | ||
|
||
static final class TypeFieldType extends StringFieldType { | ||
public static final class TypeFieldType extends StringFieldType { | ||
|
||
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(TypeFieldType.class)); | ||
public static final String TYPES_DEPRECATION_MESSAGE = | ||
"[types removal] Referring to types within search queries is deprecated, filter on a field instead."; | ||
|
||
TypeFieldType() { | ||
} | ||
|
@@ -124,6 +126,7 @@ public boolean isSearchable() { | |
|
||
@Override | ||
public Query existsQuery(QueryShardContext context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be really comprehensive, we could also override the other query types ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Julie. Turns out that |
||
deprecationLogger.deprecatedAndMaybeLog("exists_query_with_type_field", TYPES_DEPRECATION_MESSAGE); | ||
return new MatchAllDocsQuery(); | ||
} | ||
|
||
|
@@ -134,6 +137,7 @@ public Query termQuery(Object value, QueryShardContext context) { | |
|
||
@Override | ||
public Query termsQuery(List<?> values, QueryShardContext context) { | ||
deprecationLogger.deprecatedAndMaybeLog("term_query_with_type_field", TYPES_DEPRECATION_MESSAGE); | ||
DocumentMapper mapper = context.getMapperService().documentMapper(); | ||
if (mapper == null) { | ||
return new MatchNoDocsQuery("No types"); | ||
|
@@ -155,9 +159,7 @@ public Query termsQuery(List<?> values, QueryShardContext context) { | |
|
||
@Override | ||
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, QueryShardContext context) { | ||
deprecationLogger.deprecatedAndMaybeLog("range_single_type", | ||
"Running [range] query on [_type] field for an index with a single type." | ||
+ " As types are deprecated, this functionality will be removed in future releases."); | ||
deprecationLogger.deprecatedAndMaybeLog("range_query_with_type_field", TYPES_DEPRECATION_MESSAGE); | ||
Query result = new MatchAllDocsQuery(); | ||
String type = context.getMapperService().documentMapper().type(); | ||
if (type != null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should remove these reindex-related changes, and tackle them in a dedicated PR? I think there may be more updates to track down around the reindex API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtibshirani Thanks Julie. The only reason I added these changes into this PR is because
request.setSourceDocTypes("_doc");
underneath uses a query with a type that we are deprecating in this PR, and if I don't remove this line,CRUDDocumentationIT. :: testReindex
fails.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I missed that!