I would like to check if I have already created vectors with a specific namespace. Is there an API I could hit for that info?
Did you find an answer?
Hi @yangsunwoo
you can run a query with the vector and top_k = 1 then check the score. If its 1 or more the vector is already in the namespace (which you provide in the query itself).
Hope this helps
Edit. If you only want to check if a namespace with some number of vectors exists, you can use the DescribeIndexStats
here is a direct code snippet - really easy. Just grab the list and check if namespace exists via mapping.
Thank you @tim , do you have link to the Python version of this function?
Hi @muhammad.usman, the below function will accomplish the same check in Python:
def namespace_exists(index, namespace):
namespaces = index.describe_index_stats()['namespaces']
return namespace in namespaces