Description
I am trying to cross-reference collections: I can’t include a dataType to a collection that doesn’t exist which I understand but in the following scenario I want to be able crossrefence eachother
const schema = {
"classes": [
{
"class": "Author",
"properties": [
{
"name": "name",
"dataType": ["string"]
},
{
"name": "books",
"dataType": ["Book"],
"cardinality": "many"
}
]
},
{
"class": "Book",
"properties": [
{
"name": "title",
"dataType": ["string"]
},
{
"name": "authors",
"dataType": ["Author"],
"cardinality": "many"
}
]
}
]
};
How can I do this (weaviate javascript) or can I create the collection and then update the collection after all collections are created with the properties needed to crossreference?
Server Setup Information
- Weaviate Server Version: weaviate-client-ts 2.1.0
- Deployment Method: NA
- Multi Node? Number of Running Nodes:
- Client Language and Version: Typescript (weaviate-client.ts 2.10)
Any additional Information
const classWithSharding = async (
className: string,
properties: any = [],
vectorizer: string = "text2vec-openai",
distance: string = "cosine"
) => {
const classWithSharding = {
class: className,
vectorizer: vectorizer,
vectorIndexConfig: {
distance: distance,
},
properties: [],
shardingConfig: {
virtualPerPhysical: 128,
desiredCount: 1,
actualCount: 1,
desiredVirtualCount: 128,
actualVirtualCount: 128,
},
}
if (properties) classWithSharding.properties = properties
// Add the class to the schema
let result = await weaviateApp.schema
.classCreator()
.withClass(classWithSharding)
.do()
// The returned value is the full class definition, showing all defaults
console.log(JSON.stringify(result, null, 2))
return result
}