How to create schema class reference with multiple collection types as range like Airport.basedIn


Server Setup Information

  • Weaviate Server Version: 1.24.1
  • Deployment Method: Docker
  • Multi Node? Number of Running Nodes: 1
  • Client Language and Version: REST Api and Python Client

Any additional Information

I am attempting to create a schema either by using rest API or Python client where I have a reference whose type could be an xor type situation like illustrated in the test/acceptance/graphql_resolvers/fixtures/things_schema.jsont in the Airline class. I particularly need the capability to have a property where the range/datatype can be one or many collections. I have attempted to upload the schema via rest api and iteratively create it using python client and I get an error when trying to create a ReferenceProperty that a list is an invalid datatype:

      "class": "Airline",
      "description": "An organization that provides flights for passengers",
      "properties": [
          "name": "code",
          "dataType": ["string"],
          "description": "identifier for an airport"
          "name": "basedIn",
          "dataType": ["City", "Country"], <--------------------------WHAT I NEED
          "description": "City or country where the airline is based."
          "name": "name",
          "dataType": ["string"],
          "description": "Official name of the airline"
          "name": "hasNumberOfPlanes",
          "dataType": ["int"],
          "description": "Number of airplanes the airline owns"

Here is what i’m attempting to do with Python client and the error I’m getting:

ValidationError                           Traceback (most recent call last)
Cell In[13], line 19
     14         for ref in klass["references"]:
     15             # range = client.collections.get(ref["target_collection"])
     16             print(ref['target_collection'])
     18             col.config.add_reference(
---> 19                 wvc.config.ReferenceProperty(
     20                     name = ref["name"],
     21                     description=ref["description"],
     22                     target_collection= ref['target_collection']
     23                 )
     25         )
     26 finally:
     27     client.close()

File ~/.local/lib/python3.10/site-packages/pydantic/, in BaseModel.__init__(self, **data)
    169 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    170 __tracebackhide__ = True
--> 171 self.__pydantic_validator__.validate_python(data, self_instance=self)

ValidationError: 1 validation error for ReferenceProperty
  Input should be a valid string [type=string_type, input_value=['Fuse', 'Switch'], input_type=list]
    For further information visit

hi @tim_duval !

Welcome to our community :hugs: !

I am afraid this is not possible.

You can have one cross reference for each relations (basedInCity, basedInCountry)
, or one cross reference for basedIn [“CountryCity”]

Not sure if this is what you want :thinking:

Let me know if this helps!