-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Retrieve Offsets of inner_hits
#2521
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
Labels
type: bug
A general bug
Milestone
Comments
Thanks for finding, analyzing and providing a fix for this. Do you want to submit a Pull Request, otherwise I could do it as well, I copied and tested that code locally. As for why this is so? Don't know. I probably did not seem to consider the offset when implementing it and so just missed it. |
thanks for the feedback and yes, I'm happy to prepare a pr I hope to get to it tomorrow! |
JKatzwinkel
added a commit
to JKatzwinkel/spring-data-elasticsearch
that referenced
this issue
Apr 8, 2023
sothawo
pushed a commit
that referenced
this issue
Apr 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
8.6.2
spring-data-elasticsearch
:5.1.0-M3
Hi, thanks again for the excellent work, I enjoy it very much!
I'm having an issue while trying to obtain the correct offset values from
inner_hits
of a nested query viaSearchHit#getNestedMetaData
. Even though Elasticsearch responds with the expected offsets when I run my queries directly against it, the#getOffset()
return values from inner hits via#getInnerHits()
are always the same, regardless of how many inner hits are returned within an individual top-level hit.Allow me to illustrate this based on your integration test(s). They run a (nested) nested query and test the offsets of the inner hits, of which there are 1 on each nesting level:
However ☝, imagine they would look like this, now finding 2 inner hits that (as far as I understand) should have different offsets:
❌ Now the tests (
./mvnw clean verify
) fail because all of the inner hits have the same offset (1
). This is despite of Elasticsearch itself returning the offsets I expect (1
and2
in this case). I might be doing something wrong, but on the other hand the implementation responsible for mapping the inner hit offsets does contain something that confuses me (first and last line):So for each inner hit, the same nested matadata are being used (
persistendEntityWithNestedMetaData.nestedMetaData
), even though each inner inner hit should have its own metadata (_nested
object withfield
andoffset
inside) in the Elasticsearch response.There is probably a good reason for it to be implemented like this, but this seems to cause the unexpected behaviour I described above. I actually managed to fix this very easily by mapping the actual metadata of the actual inner hits respectively:
✅ After this change, the tests pass again.
Am I right to assume that the way in which I amended your integration test(s) is how you are supposed to retrieve the inner hits offsets, or am I doing something wrong?
Thanks again and happy Easter!
The text was updated successfully, but these errors were encountered: