Fix: Missing embedding_metadata in MatchNeighbor returned by find_neighbors in Vertex AI Matching Engine. #6120
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.
Summary
The
aiplatform.MatchingEngineIndexEndpoint.find_neighbors()method returns results asList[List[aiplatform.matching_engine.matching_engine_index_endpoint.MatchNeighbor]].However, the current
MatchNeighbordataclass does not expose theembedding_metadatafield,even when
return_full_datapoint=Trueand the API response includes theembeddingMetadataattribute.Issue
When
return_full_datapoint=Trueis set, the API correctly returns the full datapoint withembeddingMetadata, but this metadata is silently dropped because theMatchNeighborclass does not have a corresponding attribute to capture it.Fix
The
aiplatform_v1beta1.index.IndexDatapointclass already supportsembedding_metadata.This PR adds an
embedding_metadatafield to theMatchNeighbordataclass and populates itwithin the
MatchNeighbor.from_index_datapoint()method.Testing
Verified the fix locally by querying an index with
return_full_datapoint=True.The
embedding_metadatafield now appears correctly in the returnedMatchNeighborobjectsand matches the data returned directly from the API.
Impact
This change enables users to access
embedding_metadatawhen usingfind_neighbors()through the Python SDK, bringing it to parity with the REST API behavior.