pub struct Batch { /* private fields */ }
Expand description

All batch related endpoints and functionality described in Weaviate meta API documentation

Implementations§

source§

impl Batch

source

pub async fn objects_batch_add( &self, objects: MultiObjects, consistency_level: Option<ConsistencyLevel>, tenant: Option<&str> ) -> Result<BatchAddObjects, Box<dyn Error>>

Batch add objects.

§Parameters
  • objects: the objects to add
  • consistency_level: the consistency level to use
§Example
use uuid::Uuid;
use weaviate_community::WeaviateClient;
use weaviate_community::collections::objects::{Object, MultiObjects, ConsistencyLevel};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = WeaviateClient::builder("http://localhost:8080").build()?;

    let author_uuid = Uuid::parse_str("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").unwrap();
    let article_a_uuid = Uuid::parse_str("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").unwrap();
    let article_b_uuid = Uuid::parse_str("b72912b9-e5d7-304e-a654-66dc63c55b32").unwrap();

    let article_a = Object::builder("Article", serde_json::json!({}))
        .with_id(article_a_uuid.clone())
        .build();

    let article_b = Object::builder("Article", serde_json::json!({}))
        .with_id(article_b_uuid.clone())
        .build();

    let author = Object::builder("Author", serde_json::json!({}))
        .with_id(author_uuid.clone())
        .build();

    let res = client.batch.objects_batch_add(
        MultiObjects::new(vec![article_a, article_b, author]),
        Some(ConsistencyLevel::ALL),
        None
    ).await;

    Ok(())
}
source

pub async fn objects_batch_delete( &self, request_body: BatchDeleteRequest, consistency_level: Option<ConsistencyLevel>, tenant: Option<&str> ) -> Result<BatchDeleteResponse, Box<dyn Error>>

Batch delete objects.

§Parameters
  • request_body: the config to use for deletion
  • consistency_level: the consistency level to use
§Example
use uuid::Uuid;
use weaviate_community::WeaviateClient;
use weaviate_community::collections::objects::{Object, MultiObjects, ConsistencyLevel};
use weaviate_community::collections::batch::{BatchDeleteRequest, MatchConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = WeaviateClient::builder("http://localhost:8080").build()?;
    let req = BatchDeleteRequest::builder(
        MatchConfig::new(
            "Article",
            serde_json::json!({
                "operator": "Like",
                "path": ["id"],
                "valueText": "*4*",
            })
        )
    ).build();

    let res = client.batch.objects_batch_delete(
        req,
        Some(ConsistencyLevel::ALL),
        None
    ).await;

    Ok(())
}
source

pub async fn references_batch_add( &self, references: References, consistency_level: Option<ConsistencyLevel>, tenant: Option<&str> ) -> Result<BatchAddReferencesResponse, Box<dyn Error>>

Batch add references.

Note that the consistency_level and tenant_name in the Reference items contained within the References input bare no effect on this method and will be ignored.

§Parameters
  • references: the references to add
  • consistency_level: the consistency level to use
§Example
use uuid::Uuid;
use weaviate_community::WeaviateClient;
use weaviate_community::collections::objects::{Reference, References, ConsistencyLevel};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = WeaviateClient::builder("http://localhost:8080").build()?;

    let author_uuid = Uuid::parse_str("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").unwrap();
    let article_a_uuid = Uuid::parse_str("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").unwrap();
    let article_b_uuid = Uuid::parse_str("b72912b9-e5d7-304e-a654-66dc63c55b32").unwrap();

    let references = References::new(vec![
        Reference::new(
            "Author",
            &author_uuid,
            "wroteArticles",
            "Article",
            &article_a_uuid,
        ),
        Reference::new(
            "Author",
            &author_uuid,
            "wroteArticles",
            "Article",
            &article_b_uuid,
        ),
    ]);

    let res = client.batch.references_batch_add(
        references,
        Some(ConsistencyLevel::ALL),
        None
    ).await;

    Ok(())
}

Trait Implementations§

source§

impl Debug for Batch

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Batch

§

impl Send for Batch

§

impl Sync for Batch

§

impl Unpin for Batch

§

impl !UnwindSafe for Batch

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.

§

impl<T> Instrument for T

§

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

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

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>,

§

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>,

§

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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