Skip to content

Return distanceMetric in QueryVectors response - #284

Open
chr-hertel wants to merge 1 commit into
Robothy:mainfrom
chr-hertel:return-distance-metric-in-query-vectors
Open

Return distanceMetric in QueryVectors response#284
chr-hertel wants to merge 1 commit into
Robothy:mainfrom
chr-hertel:return-distance-metric-in-query-vectors

Conversation

@chr-hertel

Copy link
Copy Markdown

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 QueryVectors response omits the distanceMetric field, 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. emits Undefined 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 distanceMetric as 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:

    "QueryVectorsOutput": {
      "type": "structure",
      "required": ["vectors", "distanceMetric"],
      ...
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant