As mentioned here
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 ?
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):