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 percolate query's document_type parameter. #25199

Conversation

martijnvg
Copy link
Member

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)

@martijnvg martijnvg added :Search Relevance/Percolator Reverse search: find queries that match a document >deprecation review v6.0.0 labels Jun 13, 2017
Copy link
Contributor

@jpountz jpountz left a 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) {
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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?

@martijnvg martijnvg force-pushed the percolator_deprecated_document_type_parameter branch from 8c69564 to 84c7f14 Compare June 19, 2017 07:48
@martijnvg
Copy link
Member Author

@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);
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Member Author

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.

@martijnvg martijnvg force-pushed the percolator_deprecated_document_type_parameter branch from 84c7f14 to a4e699e Compare June 21, 2017 08:42
@@ -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
Copy link
Contributor

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`)
@martijnvg martijnvg force-pushed the percolator_deprecated_document_type_parameter branch from a4e699e to a977569 Compare June 22, 2017 07:58
@martijnvg martijnvg merged commit a977569 into elastic:master Jun 22, 2017
@danielmitterdorfer
Copy link
Member

@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?

@martijnvg
Copy link
Member Author

@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.

danielmitterdorfer added a commit to elastic/rally-tracks that referenced this pull request Jul 14, 2017
@danielmitterdorfer
Copy link
Member

Cool, thank you @martijnvg!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Search Relevance/Percolator Reverse search: find queries that match a document v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants