-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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 percolate query's document_type parameter. #25199
Deprecate percolate query's document_type parameter. #25199
Conversation
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 left some comments about corner cases.
*/ | ||
@Deprecated | ||
public PercolateQueryBuilder(String field, String documentType, BytesReference document) { | ||
this(field, documentType, document, XContentFactory.xContentType(document)); | ||
} | ||
|
||
public PercolateQueryBuilder(String field, BytesReference document, XContentType documentXContentType) { |
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.
javadocs?
|
||
ParsedDocument doc = docMapper.parse(source(context.index().getName(), documentType, "_temp_id", document, documentXContentType)); | ||
Collection<String> types = mapperService.types(); | ||
assert types.size() == 1; |
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.
it could be 0 if the index was just created without types?
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.
if types.size() == 1 should we throw an exception if documentType is different from type?
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.
it could be 0 if the index was just created without types?
That can happen, but that also mean that there isn't a percolator field in that case we should fail. I'll move the field validation before this part, so that check can remain the same.
if types.size() == 1 should we throw an exception if documentType is different from type?
This if statement only gets executed if index.mapping.single_type
is set to true, so then there should be only a 1 type?
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.
true, but it might not be the same type as the query type?
8c69564
to
84c7f14
Compare
@jpountz I've updated the pr. |
* @param documentXContentType The content type of the binary blob containing the document to percolate | ||
*/ | ||
public PercolateQueryBuilder(String field, BytesReference document, XContentType documentXContentType) { | ||
this(field, "doc", document, documentXContentType); |
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.
should we pass null
instead of doc
? It should work regardless of what the single type is?
if (types.size() != 1) { | ||
throw new IllegalStateException("Only a single type should exist, but [" + types.size() + " types exists"); | ||
} | ||
String type = types.iterator().next(); |
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.
we should fail if documentType is not null and documentType != type, which can happen if the query has a different type than the mapping?
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.
Good point. I added validation for this.
84c7f14
to
a4e699e
Compare
@@ -53,6 +53,10 @@ | |||
|
|||
* The `template` query has been removed. This query was deprecated since 5.0 | |||
|
|||
* The `percolate` query's `document_type` has been deprecated. From 6.0 and later | |||
it is no longer required to specify `document_type` parameter on indices with |
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.
let's end the sentence after parameter
since we plan on not allowing to set this setting at all in 6.x
The `document_type` parameter is no longer required to be specified, because by default from 6.0 only a single type is allowed. (`index.mapping.single_type` defaults to `true`)
a4e699e
to
a977569
Compare
@martijnvg I just stumbled upon this change when checking the deprecation log of our benchmarks. In the docs it still says that document_type is a required parameter. Should we change that and maybe even have a short deprecation note for this parameter? |
@danielmitterdorfer Thanks for catching this. It should be formulated differently. It is only required for indices created before 6.0. I'll update the docs. |
Cool, thank you @martijnvg! |
The
document_type
parameter is no longer required to be specified,because by default from 6.0 only a single type is allowed. (
index.mapping.single_type
defaults totrue
)