pub struct Schema { /* private fields */ }Expand description
All schema related endpoints and functionality described in Weaviate schema API documentation
Implementations§
Source§impl Schema
impl Schema
Sourcepub async fn get_class(&self, class_name: &str) -> Result<Class, Box<dyn Error>>
pub async fn get_class(&self, class_name: &str) -> Result<Class, Box<dyn Error>>
Facilitates the retrieval of the configuration for a single class in the schema.
GET /v1/schema/{class_name}
use weaviate_community::WeaviateClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let response = client.schema.get_class("Library").await;
assert!(response.is_err());
Ok(())
}Sourcepub async fn get(&self) -> Result<Classes, Box<dyn Error>>
pub async fn get(&self) -> Result<Classes, Box<dyn Error>>
Facilitates the retrieval of the full Weaviate schema.
GET /v1/schema
use weaviate_community::WeaviateClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let schema = client.schema.get().await?;
println!("{:#?}", &schema);
Ok(())
}Sourcepub async fn create_class(&self, class: &Class) -> Result<Class, Box<dyn Error>>
pub async fn create_class(&self, class: &Class) -> Result<Class, Box<dyn Error>>
Create a new data object class in the schema.
Note that from 1.5.0, creating a schema is optional, as Auto Schema is available. See for more info: Weaviate auto-schema documentation
POST /v1/schema
use weaviate_community::WeaviateClient;
use weaviate_community::collections::schema::Class;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let class = Class::builder("Library").build();
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let res = client.schema.create_class(&class).await?;
Ok(())
}Sourcepub async fn delete(&self, class_name: &str) -> Result<bool, Box<dyn Error>>
pub async fn delete(&self, class_name: &str) -> Result<bool, Box<dyn Error>>
Remove a class (and all data in the instances) from the schema.
DELETE v1/schema/{class_name}
use weaviate_community::WeaviateClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let response = client.schema.delete("Library").await;
Ok(())
}Sourcepub async fn update(&self, class: &Class) -> Result<Class, Box<dyn Error>>
pub async fn update(&self, class: &Class) -> Result<Class, Box<dyn Error>>
Update settings of an existing schema class.
Use this endpoint to alter an existing class in the schema. Note that not all settings are mutable. If an error about immutable fields is returned and you still need to update this particular setting, you will have to delete the class (and the underlying data) and recreate. This endpoint cannot be used to modify properties. A typical use case for this endpoint is to update configuration, such as the vectorIndexConfig. Note that even in mutable sections, such as vectorIndexConfig, some fields may be immutable.
You should attach a body to this PUT request with the entire new configuration of the class
Sourcepub async fn add_property(
&self,
class_name: &str,
property: &Property,
) -> Result<Property, Box<dyn Error>>
pub async fn add_property( &self, class_name: &str, property: &Property, ) -> Result<Property, Box<dyn Error>>
Add a property to an existing class in the schema.
Sourcepub async fn get_shards(
&self,
class_name: &str,
) -> Result<Shards, Box<dyn Error>>
pub async fn get_shards( &self, class_name: &str, ) -> Result<Shards, Box<dyn Error>>
View all of the shards for a particular class.
Sourcepub async fn update_class_shard(
&self,
class_name: &str,
shard_name: &str,
status: ShardStatus,
) -> Result<Shard, Box<dyn Error>>
pub async fn update_class_shard( &self, class_name: &str, shard_name: &str, status: ShardStatus, ) -> Result<Shard, Box<dyn Error>>
Update shard status
Sourcepub async fn list_tenants(
&self,
class_name: &str,
) -> Result<Tenants, Box<dyn Error>>
pub async fn list_tenants( &self, class_name: &str, ) -> Result<Tenants, Box<dyn Error>>
List tenants
Sourcepub async fn add_tenants(
&self,
class_name: &str,
tenants: &Tenants,
) -> Result<Tenants, Box<dyn Error>>
pub async fn add_tenants( &self, class_name: &str, tenants: &Tenants, ) -> Result<Tenants, Box<dyn Error>>
Add tenant