Skip to content

Commit 0870512

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add update_mask "embedding_metadata" to MatchingEngineIndex upsert_datapoints() to support embedding metadata update.
PiperOrigin-RevId: 794412935
1 parent 77f7b8e commit 0870512

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

google/cloud/aiplatform/matching_engine/matching_engine_index.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ def upsert_datapoints(
790790
Updatable fields:
791791
Use `all_restricts` to update both `restricts` and
792792
`numeric_restricts`.
793+
Use `embedding_metadata` to update `embedding_metadata`.
793794
794795
Returns:
795796
MatchingEngineIndex - Index resource object

tests/system/aiplatform/test_matching_engine_index.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
import uuid
1919

2020
from google.cloud import aiplatform
21+
from google.cloud import aiplatform_v1
2122
from google.cloud.aiplatform.matching_engine.matching_engine_index_endpoint import (
2223
Namespace,
2324
)
24-
from google.cloud import aiplatform_v1
2525
from tests.system.aiplatform import e2e_base
2626

27+
from google.protobuf import struct_pb2
28+
2729
# project
2830
_TEST_INDEX_DISPLAY_NAME = "index_display_name"
2931
_TEST_STREAM_INDEX_DISPLAY_NAME = "stream_index_display_name"
@@ -219,6 +221,13 @@
219221
)
220222
],
221223
)
224+
_TEST_DATAPOINT_4 = aiplatform_v1.types.index.IndexDatapoint(
225+
datapoint_id="upsert_4",
226+
feature_vector=_TEST_MATCH_QUERY,
227+
embedding_metadata=struct_pb2.Struct(
228+
fields={"userinfo": struct_pb2.Value(string_value="test_userinfo")}
229+
),
230+
)
222231
_TEST_STREAM_INDEX_DATAPOINTS = [
223232
_TEST_DATAPOINT_1,
224233
_TEST_DATAPOINT_2,
@@ -631,6 +640,10 @@ def test_matching_engine_stream_index(self, shared_state):
631640

632641
# Upsert datapoint to stream index
633642
stream_index.upsert_datapoints(datapoints=_TEST_STREAM_INDEX_DATAPOINTS)
643+
stream_index.upsert_datapoints(
644+
datapoints=_TEST_DATAPOINT_4,
645+
update_mask=["embedding_metadata"],
646+
)
634647

635648
# Remove datapoint upserted to stream index
636649
stream_index.remove_datapoints(datapoint_ids="upsert_0")

0 commit comments

Comments
 (0)