pub struct Query { /* private fields */ }Expand description
All GraphQL related endpoints and functionality described in Weaviate GraphQL API documentation
Implementations§
Source§impl Query
impl Query
Sourcepub async fn get(&self, query: GetQuery) -> Result<Value, Box<dyn Error>>
pub async fn get(&self, query: GetQuery) -> Result<Value, Box<dyn Error>>
Execute the Get{} GraphQL query
§Parameters
- query: the query to execute
§Example
use weaviate_community::WeaviateClient;
use weaviate_community::collections::query::GetBuilder;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let query = GetBuilder::new(
"JeopardyQuestion",
vec![
"question",
"answer",
"points",
"hasCategory { ... on JeopardyCategory { title }}"
])
.with_limit(1)
.with_additional(vec!["id"])
.build();
let res = client.query.get(query).await;
Ok(())
}Sourcepub async fn aggregate(
&self,
query: AggregateQuery,
) -> Result<Value, Box<dyn Error>>
pub async fn aggregate( &self, query: AggregateQuery, ) -> Result<Value, Box<dyn Error>>
Execute the Aggregate{} GraphQL query
§Parameters
- query: the query to execute
§Example
use weaviate_community::WeaviateClient;
use weaviate_community::collections::query::AggregateBuilder;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let query = AggregateBuilder::new("Article")
.with_meta_count()
.with_fields(vec!["wordCount {count maximum mean median minimum mode sum type}"])
.build();
let res = client.query.aggregate(query).await;
Ok(())
}Sourcepub async fn explore(
&self,
query: ExploreQuery,
) -> Result<Value, Box<dyn Error>>
pub async fn explore( &self, query: ExploreQuery, ) -> Result<Value, Box<dyn Error>>
Execute the Explore{} GraphQL query
§Parameters
- query: the query to execute
§Example
use weaviate_community::WeaviateClient;
use weaviate_community::collections::query::ExploreBuilder;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let query = ExploreBuilder::new()
.with_limit(1)
.with_near_vector("{vector: [-0.36840257,0.13973749,-0.28994447]}")
.with_fields(vec!["className"])
.build();
let res = client.query.explore(query).await;
Ok(())
}Sourcepub async fn raw(&self, query: RawQuery) -> Result<Value, Box<dyn Error>>
pub async fn raw(&self, query: RawQuery) -> Result<Value, Box<dyn Error>>
Execute a raw GraphQL query.
This method has been implemented to allow you to run your own query that doesn’t fit in with the format that is set out in this crate.
If there is a query that you think should be added, please open up a new feature request on GitHub.
§Parameters
- query: the query to execute
§Example
use weaviate_community::WeaviateClient;
use weaviate_community::collections::query::RawQuery;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = WeaviateClient::builder("http://localhost:8080").build()?;
let query = RawQuery::new("{Get{JeopardyQuestion{question answer points}}}");
let res = client.query.raw(query).await;
Ok(())
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Query
impl !RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl !UnwindSafe for Query
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