How can I retrieve a tenant based on vector similarity?

In the documentation, in order to retrieve tenant from the collection, you need the exact tenant name, which in this case is “tenantA”:

import weaviate.classes as wvc

multi_collection = client.collections.get("MultiTenancyCollection")

# Get collection specific to the required tenant
multi_tenantA = multi_collection.with_tenant("tenantA")

# Query tenantA
result = multi_tenantA.query.fetch_objects(

What if I am letting the user input a piece of text and they input “tenant a” instead of “tenantA”? Is there a way to extract the tenant based on the tenant with the closest vector similarity?

Let me give an overview of what I am storing. So in my DB, I am storing multiple maps, each with a distinct name inputted by the user (i.e. “outdoor playground”). Each map stores multiple things: key coordinates in the form of {coordinate name: coordinate} (i.e. “kitchen”: (0.4, 12.5, -34.1)) and also a graph data structure defined in python. I want the user to be able to query and retrieve a map based on vector similarity, so if they input “playground” then it should retrieve the “outdoor playground” map. Also, I’m actually not sure if storing python objects is possible in the database… Can someone please help me with this?

Can someone please help me?


You cannot search by the tenant name.

I believe the best approach here is to have total control over the tenant name, and normalize it to avoid an input with mispells, for example.

I imagine each tenant will have it’s own maps. So you can define a map_name property, for example, and will be able to query for closest objects.

So if there is a map called “outdoor playground”, it will appear when a query near this concept is done.

And no, you cannot store python objects. You will have to store this in a different format.

Let me know if this helps :slight_smile:

1 Like