ClassificationRequestBuilder

Struct ClassificationRequestBuilder 

Source
pub struct ClassificationRequestBuilder {
    pub classification_type: ClassificationType,
    pub class: String,
    pub classify_properties: Vec<String>,
    pub based_on_properties: Option<Vec<String>>,
    pub filters: Value,
    pub settings: Option<Value>,
}
Expand description

Builder for the ClassificationRequest

Fields§

§classification_type: ClassificationType§class: String§classify_properties: Vec<String>§based_on_properties: Option<Vec<String>>§filters: Value§settings: Option<Value>

Implementations§

Source§

impl ClassificationRequestBuilder

Source

pub fn new() -> ClassificationRequestBuilder

Create a new builder for the ClassificationRequest.

This is the same as ClassificationRequestBuilder::new().

The resulting object will have no populated fields. These need filling out in accordance with the required classification type using the builder methods.

§Example
use weaviate_community::collections::classification::ClassificationRequestBuilder;

let builder = ClassificationRequestBuilder::new();
Source

pub fn with_type( self, classification_type: ClassificationType, ) -> ClassificationRequestBuilder

Add a value to the classification_type property of the ClassificationRequest.

§Parameters
  • classification_type: the classification_type to use for the property
§Example
use weaviate_community::collections::classification::{
    ClassificationRequestBuilder,
    ClassificationType
};

let builder = ClassificationRequestBuilder::new()
    .with_type(ClassificationType::KNN);
Source

pub fn with_class(self, class_name: &str) -> ClassificationRequestBuilder

Add a value to the class property of the ClassificationRequest.

§Parameters
  • class_name: the name of the class to run the classification on
§Example
use weaviate_community::collections::classification::ClassificationRequestBuilder;

let builder = ClassificationRequestBuilder::new()
    .with_class("Article");
Source

pub fn with_classify_properties( self, classify_properties: Vec<&str>, ) -> ClassificationRequestBuilder

Add a value to the classify_properties property of the ClassificationRequest.

§Parameters
  • classify_properties: the properties to classify
§Example
use weaviate_community::collections::classification::ClassificationRequestBuilder;

let builder = ClassificationRequestBuilder::new()
    .with_classify_properties(vec!["hasPopularity"]);
Source

pub fn with_based_on_properties( self, based_on_properties: Vec<&str>, ) -> ClassificationRequestBuilder

Add a value to the based_on_properties property of the ClassificationRequest.

§Parameters
  • based_on_properties: the ‘based on’ properties to classify against
§Example
use weaviate_community::collections::classification::ClassificationRequestBuilder;

let builder = ClassificationRequestBuilder::new()
    .with_based_on_properties(vec!["summary"]);
Source

pub fn with_filters(self, filters: Value) -> ClassificationRequestBuilder

Add a value to the filters property of the ClassificationRequest.

§Parameters
  • filters: the filters for the classifier to use when retrieving results
§Example
use weaviate_community::collections::classification::ClassificationRequestBuilder;

let builder = ClassificationRequestBuilder::new()
    .with_filters(serde_json::json!(
        {"path": ["wordCount"], "operator": "GreaterThan", "valueInt": 100}
    ));
Source

pub fn with_settings(self, settings: Value) -> ClassificationRequestBuilder

Add a value to the settings property of the ClassificationRequest.

§Parameters
  • settings: the settings for the classifier
§Example
use weaviate_community::collections::classification::ClassificationRequestBuilder;

let builder = ClassificationRequestBuilder::new()
    .with_settings(serde_json::json!({"k": 3}));
Source

pub fn build(self) -> ClassificationRequest

Build the ClassificationRequest from the ClassificationRequestBuilder

§Example

Using ClassificationRequestBuilder

use weaviate_community::collections::classification::{
    ClassificationRequestBuilder,
    ClassificationType
};

let builder = ClassificationRequestBuilder::new()
    .with_type(ClassificationType::KNN)
    .with_class("Article")
    .with_classify_properties(vec!["hasPopularity"])
    .with_based_on_properties(vec!["summary"])
    .with_filters(serde_json::json!(
        {"path": ["wordCount"], "operator": "GreaterThan", "valueInt": 100}
    ))
    .with_settings(serde_json::json!({"k": 3}))
    .build();

Using ClassificationRequest

use weaviate_community::collections::classification::{
    ClassificationRequest,
    ClassificationType
};

let builder = ClassificationRequest::builder()
    .with_type(ClassificationType::KNN)
    .with_class("Article")
    .with_classify_properties(vec!["hasPopularity"])
    .with_based_on_properties(vec!["summary"])
    .with_filters(serde_json::json!(
        {"path": ["wordCount"], "operator": "GreaterThan", "valueInt": 100}
    ))
    .with_settings(serde_json::json!({"k": 3}))
    .build();

Trait Implementations§

Source§

impl Debug for ClassificationRequestBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ClassificationRequestBuilder

Source§

fn default() -> ClassificationRequestBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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