# Multi-tenant cross-reference

**URL:** <https://forum.weaviate.io/t/multi-tenant-cross-reference/1784>\
**Category:** Support\
**Created:** [March 21, 2024, 11:41am UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784 "2024-03-21T11:41:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [March 21, 2024, 11:41am UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/1 "2024-03-21T11:41:20Z")

</div>

### Description

As mentioned [here](https://weaviate.io/developers/weaviate/manage-data/multi-tenancy#cross-references)  
A cross-reference can be added from a multi-tenancy collection object to:

- A non-multi-tenancy collection object,

problem Statement:  
I have two class A { price, Has\_Item} & B { item} .  
A with multi tenancy and B with without it.  
I have CrossRef from A → B  
When I tried to fetch information from

jeopardy = client.collections.get(“A”).with\_tenant(‘1234’)  
response = jeopardy.query.fetch\_objects(  
return\_references=wvc.query.QueryReference(link\_on=“Has\_Item”, return\_properties=[“item”]),  
return\_properties=[‘price’]  
)  
for o in response.objects:  
print(o.properties)  
print(o.references[“Has\_Item”].objects[0].properties[“item”])

Above query gives error such as  
list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index “B”: class B has multi-tenancy disabled, but request was with tenant.

How should i read those object as weaviate already mentioned they are supporting this type of cross-ref ?

### Server Setup Information

- Weaviate Server Version: latest version
- Client Language and Version: V4

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [March 21, 2024, 7:01pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/2 "2024-03-21T19:01:04Z")

</div>

Hi!

This scenario is interesting to create a notebook so it gets easily reproducible.

I will be away the next couple days, but could do that when I get back.

Thanks!

---

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [March 28, 2024, 3:14pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/3 "2024-03-28T15:14:14Z")

</div>

I’m waiting for your response ?

---

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [April 1, 2024, 12:19pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/4 "2024-04-01T12:19:09Z")

</div>

Help me solve this puzzle

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [April 5, 2024, 9:18pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/5 "2024-04-05T21:18:10Z")

</div>

hi @2020ashish ! Really sorry.

I was out those days and only got back now 😬

Were you able to reproduce something?

---

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [April 6, 2024, 5:42pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/6 "2024-04-06T17:42:19Z")

</div>

No, still on same page.

---

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [May 10, 2024, 5:00am UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/7 "2024-05-10T05:00:46Z")

</div>

@DudaNogueira Kindly take a look at this above one.

---

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [June 27, 2024, 11:34am UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/8 "2024-06-27T11:34:55Z")

</div>

@DudaNogueira Please take a look on this status on this.

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [June 27, 2024, 1:26pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/9 "2024-06-27T13:26:04Z")

</div>

hi @2020ashish !! Sorry here again 😬

I was able to reproduce this:

```auto
from weaviate.classes import config

collection_b = client.collections.create(
    "CollectionB",
    properties=[
        config.Property(name="text", data_type=config.DataType.TEXT)
    ]
)

collection_a = client.collections.create(
    "CollectionA",
    multi_tenancy_config=config.Configure.multi_tenancy(
        enabled=True, auto_tenant_creation=True, auto_tenant_activation=True
    ),
    properties=[
        config.Property(name="price", data_type=config.DataType.TEXT)
    ],
    references=[
        config.ReferenceProperty(
            name="has_item", target_collection="CollectionB"
        )]
)

from weaviate.util import generate_uuid5
# add some content for classB, non multi tenant - Item
collection_b.data.insert({"text": "computer"}, uuid=generate_uuid5("computer"))
collection_b.data.insert({"text": "mouse"}, uuid=generate_uuid5("mouse"))

# now we get the collection with tenant 1234
collection_a_tenant = collection_a.with_tenant("1234")
#classa_tenant = class_a

# now we add an object, cross referencing a non tenant collection
collection_a_tenant.data.insert(
    properties={"price": "1"},
    references={"has_item": generate_uuid5("computer")}
)

from weaviate.classes import query
result = collection_a_tenant.query.fetch_objects(
    return_references=query.QueryReference(
       link_on="has_item", return_properties=["text"]
    )
)

```

the error:

> WeaviateQueryError: Query call with protocol GRPC search failed with message explorer: list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index “collectionb”: class CollectionB has multi-tenancy disabled, but request was with tenant.

**Let me know if this is close to what you are after.**

According to docs. it should be possible to cross reference a non multi tenant collection (on this case, ClassB):

> **[Multi-tenancy operations | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/manage-data/multi-tenancy#cross-references)**
>
> Multi-tenancy provides data isolation. Each tenant is stored on a separate shard. Data stored in one tenant is not visible to another tenant. If your application serves many different users, multi-tenancy keeps their data private and makes database...

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [June 27, 2024, 1:29pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/10 "2024-06-27T13:29:03Z")

</div>

Ps: I also tried pyv3 version:

```auto
clientv3 = weaviate.Client("http://localhost:8080")
response = (
    clientv3.query
    .get(
        "ClassA",
        ["price", "has_Item { ... on ClassB { text } }"],
    )
    .with_limit(2).with_tenant("1234").do()
)

```

and got a similar error ( but the check was inverted)

> {‘data’: {‘Get’: {‘ClassA’: None}},  
> ‘errors’: [{‘locations’: [{‘column’: 6, ‘line’: 1}],  
> ‘message’: ‘explorer: list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index “classb”: class ClassB has multi-tenancy disabled, but request was with tenant’,  
> ‘path’: [‘Get’, ‘ClassA’]}]}

---

<div class="post-metadata">

**Author:** ![2020ashish](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/2020ashish/32/797_2.png) [@2020ashish](https://forum.weaviate.io/u/2020ashish)\
**Post date:** [June 27, 2024, 2:02pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/11 "2024-06-27T14:02:57Z")

</div>

yes it is same think.  
please check if it is possible to fetch data as mentioned in document.

---

<div class="post-metadata">

**Author:** ![Paul\_Hechinger](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/paul_hechinger/32/1996_2.png) [@Paul\_Hechinger](https://forum.weaviate.io/u/Paul_Hechinger)\
**Post date:** [July 20, 2024, 10:25pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/12 "2024-07-20T22:25:31Z")

</div>

Hey, has this issue been fixed?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [July 23, 2024, 12:42pm UTC](https://forum.weaviate.io/t/multi-tenant-cross-reference/1784/13 "2024-07-23T12:42:06Z")

</div>

hi @Paul_Hechinger !!

Welcome to our community 🤗

We have reproduced this and have a GH issue here:

> <https://github.com/weaviate/weaviate/issues/5269>
>
> \### How to reproduce this bug?
> 
> As per the weaviate documentation one should be …able to cross reference from a multi tenant to a non multi tenant.
> 
> Run the below script
> \`\`\`
> import random
> import string
> from weaviate.classes.config import Property, DataType, ReferenceProperty
> import weaviate
> import weaviate.classes.config as wvc
> from weaviate.classes.tenants import Tenant
> from weaviate.classes.query import QueryReference
> 
> client = weaviate.connect\_to\_local()
> 
> \# Create collection
> if (client.collections.exists("JeopardyCategory")):
> # delete collection "Article" - THIS WILL DELETE THE COLLECTION AND ALL ITS DATA
> client.collections.delete("JeopardyCategory") # Replace with your collection name
> 
> \# Create collection
> if (client.collections.exists("JeopardyQuestion")):
> # delete collection "Article" - THIS WILL DELETE THE COLLECTION AND ALL ITS DATA
> client.collections.delete("JeopardyQuestion") # Replace with your collection name
> 
> 
> category = client.collections.create(
> name="JeopardyCategory",
> description="A Jeopardy! category",
> properties=\[
> Property(name="title", data\_type=DataType.TEXT)
> \],
> replication\_config=wvc.Configure.replication(factor=1),
>     
> )
> 
> 
> jeopardy\_question= client.collections.create(
> name="JeopardyQuestion",
> description="A Jeopardy! question",
> properties=\[
> Property(name="question", data\_type=DataType.TEXT),
> Property(name="answer", data\_type=DataType.TEXT),
> \],
> references=\[
> ReferenceProperty(
> name="hasCategory",
> target\_collection="JeopardyCategory"
> )
> \],
> replication\_config=wvc.Configure.replication(factor=1),
> multi\_tenancy\_config=wvc.Configure.multi\_tenancy(enabled=True, auto\_tenant\_creation=True, auto\_tenant\_activation=True)
> 
> )
> 
> \# Create tenant on JeopardyQuestion
> jeopardy\_question.tenants.create(
> tenants=\[
> Tenant(name="tenantA"),
> Tenant(name="tenantB"),
> \]
> )
> 
> \# Insert objects to the collection
> def get\_random\_string(length):
> # choose from all lowercase letter
> letters = string.ascii\_lowercase
> result\_str = ''.join(random.choice(letters) for i in range(length))
> return result\_str
> # print("Random string of length", length, "is:", result\_str)
> 
> \# Add category to JeopardyCategory
> 
> jeopardy = client.collections.get("JeopardyCategory")
> 
> category\_uuid = jeopardy.data.insert({
> "title": get\_random\_string(10)
> })
> 
> questions= jeopardy\_question.with\_tenant(tenant="tenantA")
> 
> questions.data.insert({
> "question": "question" + get\_random\_string(10),
> "answer" : "answer"+ get\_random\_string(10)
> },
> references={"hasCategory": category\_uuid}, # e.g. {"hasCategory": "583876f3-e293-5b5b-9839-03f455f14575"}
> )
> 
> response = questions.query.fetch\_objects(return\_references=QueryReference(link\_on="hasCategory", return\_properties=\["question", "answer"\]))
> 
> for o in response.objects:
> print(o.properties)
> 
> client.close()
> 
> \`\`\`
> 
> \### What is the expected behavior?
> 
> No error should be displayed and user should be able to query the reference property in a multitenant collection.
> 
> \### What is the actual behavior?
> 
> \`\`\`
> weaviate.exceptions.WeaviateQueryError: Query call with protocol GRPC search failed with message \<AioRpcError of RPC that terminated with:
> status = StatusCode.UNKNOWN
> details = "explorer: list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index "jeopardycategory": class JeopardyCategory has multi-tenancy disabled, but request was with tenant"
> debug\_error\_string = "UNKNOWN:Error received from peer {created\_time:"2024-07-01T19:38:14.318273+01:00", grpc\_status:2, grpc\_message:"explorer: list class: search: resolve cross-refs: build reference cache: build request cache: fetch job list: index \\"jeopardycategory\\": class JeopardyCategory has multi-tenancy disabled, but request was with tenant"}"
> \>.
> 
> \`\`\`
> 
> \### Supporting information
> 
> https://weaviate.io/developers/weaviate/manage-data/multi-tenancy#cross-references
> 
> \### Server Version
> 
> 1.25.6
> 
> \### Code of Conduct
> 
> \- \[X\] I have read and agree to the Weaviate's \[Contributor Guide\](https://weaviate.io/developers/contributor-guide) and \[Code of Conduct\](https://weaviate.io/service/code-of-conduct)

Our team will look into this as soon as they have capacity!

Thanks!
