Schema

Struct Schema 

Source
pub struct Schema { /* private fields */ }
Expand description

All schema related endpoints and functionality described in Weaviate schema API documentation

Implementations§

Source§

impl Schema

Source

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(())
}
Source

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(())
}
Source

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(())
}
Source

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(())
}
Source

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

Source

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.

Source

pub async fn get_shards( &self, class_name: &str, ) -> Result<Shards, Box<dyn Error>>

View all of the shards for a particular class.

Source

pub async fn update_class_shard( &self, class_name: &str, shard_name: &str, status: ShardStatus, ) -> Result<Shard, Box<dyn Error>>

Update shard status

Source

pub async fn list_tenants( &self, class_name: &str, ) -> Result<Tenants, Box<dyn Error>>

List tenants

Source

pub async fn add_tenants( &self, class_name: &str, tenants: &Tenants, ) -> Result<Tenants, Box<dyn Error>>

Add tenant

Source

pub async fn remove_tenants( &self, class_name: &str, tenants: &Vec<&str>, ) -> Result<bool, Box<dyn Error>>

Remove tenants

Source

pub async fn update_tenants( &self, class_name: &str, tenants: &Tenants, ) -> Result<Tenants, Box<dyn Error>>

Update tenants

For updating tenants, both name and activity_status are required.

Note that tenant activity status setting is only available from Weaviate v1.21

Trait Implementations§

Source§

impl Debug for Schema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Schema

§

impl !RefUnwindSafe for Schema

§

impl Send for Schema

§

impl Sync for Schema

§

impl Unpin for Schema

§

impl !UnwindSafe for Schema

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more