Return distanceMetric in QueryVectors response - #284
Open
chr-hertel wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there, first of all, thanks for your work here!
I was adopting it for a test suite around vector stores (see symfony/ai#2311), but ran into the issue that the SDK we're using is issuing a warning while using it instead of AWS - since i usually try to address issues i find upstream, i wanted to jump on it - i'm not fluent in java tho.
if you don't appreciate ai-assisted contributions, you can basically convert this into an issue and close - just want to offer support, not extra burden.
Cheers Chris
Summary + References to relevant docs by Claude Code
Summary
The
QueryVectorsresponse omits thedistanceMetricfield, although AWS declares it as required in the S3 Vectors API model (QueryVectorsOutput.required = ["vectors", "distanceMetric"]). SDKs that follow the model therefore fail or warn while parsing the response - the AWS PHP SDK (async-aws) e.g. emitsUndefined array key "distanceMetric"on every query.Before:
{"vectors":[{"distance":0.0,"key":"a","metadata":{"name":"third"}}]}After:
{"vectors":[{"distance":0.0,"key":"a","metadata":{"name":"third"}}],"distanceMetric":"cosine"}References
QueryVectors API reference lists
distanceMetricas a response element: "The distance metric that was used for the similarity search calculation. This is the same distance metric that was configured for the vector index when it was created." (Type: String, Valid Values:euclidean | cosine)S3 Vectors API model declares the field as required, which is why generated SDKs read it unconditionally: