-
Notifications
You must be signed in to change notification settings - Fork 191
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
Removed required index for Hit.java #831
Conversation
For InnerHits, since the index and id is assumed to be the same as parent, they were not included in the InnerHit object, but when converting it into a Hit object in the java sdk, it would throw an exception, saying index is required. Removed it, and also added unit tests.
For InnerHits, since the index and id is assumed to be the same as parent, they were not included in the InnerHit object, but when converting it into a Hit object in the java sdk, it would throw an exception, saying index is required. Removed it, and also added unit tests. Signed-off-by: jvan1997 <[email protected]>
…nsearch-project#828) * Bump com.diffplug.spotless from 6.24.0 to 6.25.0 in /java-client Bumps com.diffplug.spotless from 6.24.0 to 6.25.0. --- updated-dependencies: - dependency-name: com.diffplug.spotless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update changelog Signed-off-by: dependabot[bot] <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com> Signed-off-by: jvan1997 <[email protected]>
For InnerHits, since the index and id is assumed to be the same as parent, they were not included in the InnerHit object, but when converting it into a Hit object in the java sdk, it would throw an exception, saying index is required. Removed it, and also added unit tests. Signed-off-by: jvan1997 <[email protected]>
@@ -107,7 +107,7 @@ public class Hit<TDocument> implements JsonpSerializable { | |||
|
|||
private Hit(Builder<TDocument> builder) { | |||
|
|||
this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); | |||
this.index = builder.index; |
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.
How do you ensure that this is only for a inner hit ? And outer hits should enforce requireNonNull
.
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 do think this is a good call out; The problem is that the the InnerHit is in a List in HitsMetadata, which is then in the InnerHitsResult.
So unless there is a file made explicitly to represent an InnerHit (which I think is a valid path), the other option would be to re-populate the Index and the Id to the InnerHits as well, even if they match the parent, or a third option to create a flag that allows a hit to know whether it is an InnerHit or main Hit.
import org.opensearch.client.json.JsonpMapper; | ||
import org.opensearch.client.json.jsonb.JsonbJsonpMapper; | ||
|
||
public class InnerHitsResultTest { |
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.
Do we have unit tests for outer hits with nullable ? Should be allowed or not allowed ?
For InnerHits, since the index and id is assumed to be the same as parent, they were not included in the InnerHit object, but when converting it into a Hit object in the java sdk, it would throw an exception, saying index is required. Removed it, and also added unit tests.
Description
Describe what this change achieves.
Change removes the required field for index in the Hit.java
Issues Resolved
Closes #825
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.