Skip to content

Fix missing parent document type specification in hasChild query example #2900

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

Conversation

1autodidact
Copy link
Contributor

Description:

1、This pull request addresses an issue in the Spring Data Elasticsearch documentation where the specification of the parent document type is missing in the example code for the hasChild query.

2、The Routing property in the Statement class is incorrectly typed as Routing, when it should be String according to the context.
3、In the example code, there is a typo where a comma is used instead of a period: .withText("+1 for the sun") ,withRouting(savedWeather.getId()), where it should be .withText("+1 for the sun").withRouting(savedWeather.getId()).

In Elasticsearch 8.x, it's essential to specify the parent document type when using the hasChild query. Failure to specify the parent type results in an error from Elasticsearch. This pull request adds the missing .type("answer") statement to ensure the correct behavior of the query.

Changes Made:

Added .type("answer") statement to specify the parent document type in the hasChild query.
Updated the example code to reflect the correct usage of the hasChild query.
References:

Elasticsearch Documentation: has_child query

ClientVersion:
elastic-search-java :8.10.4

Excption:
co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'HasChildQuery.type'
at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery.(HasChildQuery.java:82)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery.(HasChildQuery.java:51)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery$Builder.build(HasChildQuery.java:349)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery$Builder.build(HasChildQuery.java:216)
at co.elastic.clients.elasticsearch._types.query_dsl.Query$Builder.hasChild(Query.java:1412)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 21, 2024
@sothawo sothawo merged commit 106b513 into spring-projects:main Apr 21, 2024
@sothawo
Copy link
Collaborator

sothawo commented Apr 21, 2024

Thanks for finding and fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants