Struct weaviate_community::Batch
source · pub struct Batch { /* private fields */ }
Expand description
All batch related endpoints and functionality described in Weaviate meta API documentation
Implementations§
source§impl Batch
impl Batch
sourcepub async fn objects_batch_add(
&self,
objects: MultiObjects,
consistency_level: Option<ConsistencyLevel>,
tenant: Option<&str>
) -> Result<BatchAddObjects, Box<dyn Error>>
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(())
}
sourcepub async fn objects_batch_delete(
&self,
request_body: BatchDeleteRequest,
consistency_level: Option<ConsistencyLevel>,
tenant: Option<&str>
) -> Result<BatchDeleteResponse, Box<dyn Error>>
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(())
}
sourcepub async fn references_batch_add(
&self,
references: References,
consistency_level: Option<ConsistencyLevel>,
tenant: Option<&str>
) -> Result<BatchAddReferencesResponse, Box<dyn Error>>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more