Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Matching Engine shows restricts=None when finding nearest neighbors

I have a matching engine set up on a VPC. I can upload and query datapoints, but I'm trying to store metadata in the `restricts` attribute and it doesn't seem to contain it when I query.

When I create my datapoint, it seems like the restricts attribute is there:

metadata = [
aiplatform_v1.IndexDatapoint.Restriction(namespace='color', allow_list=['red']),
aiplatform_v1.IndexDatapoint.Restriction(namespace='size', allow_list=['medium'])
]

emb_query = [[.5, .5]]

# Create datapoint
id = 101
datapoints = [
aiplatform_v1.IndexDatapoint(
datapoint_id=str(id),
feature_vector=emb_query[0],
restricts=metadata
)
]

print(id, datapoints[0])
# (101,
# datapoint_id: "101"
# feature_vector: 0.5
# feature_vector: 0.5
# restricts {
# namespace: "color"
# allow_list: "red"
# }
# restricts {
# namespace: "size"
# allow_list: "medium"
# })

So far so good. Now I create the request and send it:

upsert_request = aiplatform_v1.UpsertDatapointsRequest(
index=index_name, datapoints=datapoints
)

client.index_client.upsert_datapoints(request=upsert_request)

Now, for whatever reason, when I query it back, the `MatchNeighbor` doesn't have the `restricts` attribute set:

# Fetch the endpoint
my_index_endpoint = aiplatform.MatchingEngineIndexEndpoint(
index_endpoint_name=INDEX_ENDPOINT_NAME
)

# Execute the request
response = my_index_endpoint.match(
deployed_index_id=DEPLOYED_INDEX_ID,
queries=[QUERY_EMBEDDING],
# The number of nearest neighbors to be retrieved
num_neighbors=1,
)

# print(response)
response[0]
# [MatchNeighbor(id='101', distance=1.0, feature_vector=None, crowding_tag=None, restricts=None, numeric_restricts=None)]

So why is the ``restricts`` attribute now None in this matching neighbor?

0 REPLIES 0