Noizu.Weaviate.Api.Objects (Noizu Weaviate v0.1.0)
Functions for interacting with data objects in Weaviate.
Summary
Functions
Add a cross-reference to a data object in Weaviate.
Check if a data object exists in Weaviate.
Create a new data object in Weaviate.
Get a data object in Weaviate by ID.
List data objects in Weaviate.
Update a cross-reference in Weaviate.
Update a data object in Weaviate.
Validate a data object in Weaviate.
Functions
add_cross_reference(class_name, id, property_name, beacon, options \\ nil)
@spec add_cross_reference( String.t(), String.t(), String.t(), String.t(), options :: any() ) :: {:ok, WeaviateStructs.RespObj} | {:error, any()}
Add a cross-reference to a data object in Weaviate.
Parameters
class_name
(required) - The name of the class that the data object belongs to.id
(required) - The ID of the data object.property_name
(required) - The name of the property to add the cross-reference to.beacon
(required) - The beacon URL of the reference, in the format "weaviate://localhost/<ClassName>/<id>".options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
{:ok, response} = Noizu.Weaviate.Api.Objects.add_cross_reference("Person", "12345678-1234-1234-1234-1234567890ab", "friends", "weaviate://localhost/Person/87654321-4321-4321-4321-210987654321")
check_if_data_object_exists(class_name, id, options \\ nil)
@spec check_if_data_object_exists(String.t(), String.t(), options :: any()) :: {:ok, boolean()} | {:error, any()}
Check if a data object exists in Weaviate.
Parameters
class_name
(required) - The name of the class that the data object belongs to.id
(required) - The ID of the data object.options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, exists}
on successful API call, where exists
is a boolean indicating if the data object exists.
Returns {:error, term}
on failure, where term
contains error details.
Examples
{:ok, exists} = Noizu.Weaviate.Api.Objects.check_if_data_object_exists("Product", "12345678-1234-1234-1234-1234567890ab")
create_data_object(class_name, properties, options \\ nil)
@spec create_data_object(String.t(), map(), options :: any()) :: {:ok, WeaviateStructs.RespObj} | {:error, any()}
Create a new data object in Weaviate.
Parameters
class_name
(required) - The class name as defined in the schema.properties
(required) - An object with the property values of the new data object.id
(optional) - An optional ID for the object.vector
(optional) - An optional custom vector.tenant
(optional) - An optional tenant name.options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
properties = %{name: "Apple", color: "Red"}
{:ok, response} = Noizu.Weaviate.Api.Objects.create_data_object("Product", properties)
get_data_object(class_name, id, options \\ nil)
@spec get_data_object(String.t(), String.t(), options :: any()) :: {:ok, WeaviateStructs.RespObj} | {:error, any()}
Get a data object in Weaviate by ID.
Parameters
class_name
(required) - The class name of the data object.id
(required) - The ID of the data object to fetch.options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
{:ok, response} = Noizu.Weaviate.Api.Objects.get_data_object("Product", "1234-abcd-5678-efgh")
list_data_objects(opts \\ %{})
List data objects in Weaviate.
Parameters
class
(optional) - The class name to filter the data objects by.limit
(optional) - The maximum number of data objects to return. Default is 25.offset
(optional) - The offset of data objects returned (the starting index of the returned objects). Cannot be used withafter
. Should be used in conjunction withlimit
.after
(optional) - The ID of the object after which (i.e. non-inclusive ID) objects are to be listed. Must be used withclass
. Cannot be used withoffset
orsort
. Should be used in conjunction withlimit
.include
(optional) - Additional information to include, such as classification info. Allowed values include: classification, vector, featureProjection, and other module-specific additional properties.sort
(optional) - Name of the property to sort by. You can also provide multiple names separated by commas.order
(optional) - Order in which to sort by. Possible values are "asc" (default) and "desc". Should be used in conjunction withsort
.options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
{:ok, response} = Noizu.Weaviate.Api.Objects.list_data_objects()
{:ok, response} = Noizu.Weaviate.Api.Objects.list_data_objects(class: "Product", limit: 10)
update_cross_reference(class_name, id, property_name, beacon, options \\ nil)
@spec update_cross_reference( String.t(), String.t(), String.t(), String.t(), options :: any() ) :: {:ok, WeaviateStructs.RespObj} | {:error, any()}
Update a cross-reference in Weaviate.
Parameters
class_name
(required) - The name of the class of the source object.id
(required) - The ID of the source object.property_name
(required) - The name of the property containing the cross-reference.beacon
(required) - The beacon URL of the reference, in the format "weaviate://localhost/<ClassName>/<id>".options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
{:ok, response} = Noizu.Weaviate.Api.Objects.update_cross_reference("Product", "1234", "relatedProducts", "weaviate://localhost/Product/5678")
update_data_object(class_name, id, properties, options \\ nil)
@spec update_data_object(String.t(), String.t(), [map()], options :: any()) :: {:ok, WeaviateStructs.RespObj} | {:error, any()}
Update a data object in Weaviate.
Parameters
class_name
(required) - The name of the class that the data object belongs to.id
(required) - The ID of the data object.properties
(required) - The updated property values of the data object.options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
properties = [
%{"name" => "John Doe"},
%{"age" => 30}
]
{:ok, response} = Noizu.Weaviate.Api.Objects.update_data_object("Person", "12345678-1234-1234-1234-1234567890ab", properties)
validate_data_object(class_name, properties, id \\ "", options \\ nil)
@spec validate_data_object(String.t(), [map()], String.t(), options :: any()) :: {:ok, WeaviateStructs.RespObj} | {:error, any()}
Validate a data object in Weaviate.
Parameters
class_name
(required) - The name of the class that the data object belongs to.properties
(required) - The property values of the data object to be validated.id
(optional) - The ID of the data object.options
(optional) - Additional options for the API call.
Returns
A tuple {:ok, response}
on successful API call, where response
is the API response.
Returns {:error, term}
on failure, where term
contains error details.
Examples
properties = [
%{"name" => "John Doe"},
%{"age" => 30}
]
{:ok, response} = Noizu.Weaviate.Api.Objects.validate_data_object("Person", properties)