Reputation: 4081
I have a matching engine set up in Google Cloud that is on a VPC. I'm uploading vectors and trying to use the restricts
attribute to save some metadata for limiting searches later on.
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])
This prints:
(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?
Upvotes: 0
Views: 134