weaviate.collections package

class weaviate.collections.Collection(connection: ConnectionV4, name: str, validate_arguments: bool, consistency_level: ConsistencyLevel | None = None, tenant: str | None = None, properties: Type[Properties] | None = None, references: Type[References] | None = None)[source]

Bases: Generic[Properties, References], _CollectionBase[Properties, References]

The collection class is the main entry point for interacting with a collection in Weaviate.

This class is returned by the client.collections.create and client.collections.get methods. It provides access to all the methods available to you when interacting with a collection in Weaviate.

You should not need to instantiate this class yourself but it may be useful to import this as a type when performing type hinting of functions that depend on a collection object.

Attributes:
aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

aggregate_group_by

This namespace includes all the aggregate methods available to you when using Weaviate’s aggregation group-by capabilities.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

query_group_by

This namespace includes all the querying methods available to you when using Weaviate’s querying group-by capabilities.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

backup

This namespace includes all the backup methods available to you when backing up a collection in Weaviate.

batch

This namespace contains all the functionality to upload data in batches to Weaviate for this specific collection.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

exists() bool[source]

Check if the collection exists in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[Properties, References][source]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[Properties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[Properties, TReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[TProperties, References]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[TProperties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[TProperties, TReferences]

Use this method to return an iterator over the objects in the collection.

This iterator keeps a record of the last object that it returned to be used in each subsequent call to Weaviate. Once the collection is exhausted, the iterator exits.

If return_properties is not provided, all the properties of each object will be requested from Weaviate except for its vector as this is an expensive operation. Specify include_vector to request the vector back as well. In addition, if return_references=None then none of the references are returned. Use wvc.QueryReference to specify which references to return.

Arguments:
include_vector

Whether to include the vector in the metadata of the returned objects.

return_metadata

The metadata to return with each object.

return_properties

The properties to return with each object.

return_references

The references to return with each object.

after

The cursor to use to mark the initial starting point of the iterator in the collection.

cache_size

How many objects should be fetched in each request to Weaviate during the iteration. The default is 100.

Raises:
weaviate.exceptions.WeaviateGRPCQueryError:

If the request to the Weaviate server fails.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

shards() List[Shard][source]

Get the statuses of all the shards of this collection.

Returns:

The list of shards belonging to this collection.

Raises
weaviate.WeaviateConnectionError

If the network connection to weaviate fails.

weaviate.UnexpectedStatusCodeError

If weaviate reports a none OK status.

weaviate.EmptyResponseError

If the response is empty.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

with_consistency_level(consistency_level)
with_tenant(tenant)
class weaviate.collections.CollectionAsync(connection: ConnectionV4, name: str, validate_arguments: bool, consistency_level: ConsistencyLevel | None = None, tenant: str | None = None, properties: Type[Properties] | None = None, references: Type[References] | None = None)[source]

Bases: Generic[Properties, References], _CollectionBase[Properties, References]

The collection class is the main entry point for interacting with a collection in Weaviate.

This class is returned by the client.collections.create and client.collections.get methods. It provides access to all the methods available to you when interacting with a collection in Weaviate.

You should not need to instantiate this class yourself but it may be useful to import this as a type when performing type hinting of functions that depend on a collection object.

Attributes:
aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

aggregate_group_by

This namespace includes all the aggregate methods available to you when using Weaviate’s aggregation group-by capabilities.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

query_group_by

This namespace includes all the querying methods available to you when using Weaviate’s querying group-by capabilities.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

backup

This namespace includes all the backup methods available to you when backing up a collection in Weaviate.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

async exists() bool[source]

Check if the collection exists in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[Properties, References][source]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[Properties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[Properties, TReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[TProperties, References]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[TProperties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[TProperties, TReferences]

Use this method to return an iterator over the objects in the collection.

This iterator keeps a record of the last object that it returned to be used in each subsequent call to Weaviate. Once the collection is exhausted, the iterator exits.

If return_properties is not provided, all the properties of each object will be requested from Weaviate except for its vector as this is an expensive operation. Specify include_vector to request the vector back as well. In addition, if return_references=None then none of the references are returned. Use wvc.QueryReference to specify which references to return.

Arguments:
include_vector

Whether to include the vector in the metadata of the returned objects.

return_metadata

The metadata to return with each object.

return_properties

The properties to return with each object.

return_references

The references to return with each object.

after

The cursor to use to mark the initial starting point of the iterator in the collection.

cache_size

How many objects should be fetched in each request to Weaviate during the iteration. The default is 100.

Raises:
weaviate.exceptions.WeaviateGRPCQueryError:

If the request to the Weaviate server fails.

async length() int[source]

Get the total number of objects in the collection.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

async shards() List[Shard][source]

Get the statuses of all the shards of this collection.

Returns:

The list of shards belonging to this collection.

Raises
weaviate.WeaviateConnectionError

If the network connection to weaviate fails.

weaviate.UnexpectedStatusCodeError

If weaviate reports a none OK status.

weaviate.EmptyResponseError

If the response is empty.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

async to_string() str[source]

Return a string representation of the collection object.

with_consistency_level(consistency_level)
with_tenant(tenant)

Subpackages

Submodules

weaviate.collections.aggregate module

weaviate.collections.collection module

class weaviate.collections.collection.Collection(connection: ConnectionV4, name: str, validate_arguments: bool, consistency_level: ConsistencyLevel | None = None, tenant: str | None = None, properties: Type[Properties] | None = None, references: Type[References] | None = None)[source]

Bases: Generic[Properties, References], _CollectionBase[Properties, References]

The collection class is the main entry point for interacting with a collection in Weaviate.

This class is returned by the client.collections.create and client.collections.get methods. It provides access to all the methods available to you when interacting with a collection in Weaviate.

You should not need to instantiate this class yourself but it may be useful to import this as a type when performing type hinting of functions that depend on a collection object.

Attributes:
aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

aggregate_group_by

This namespace includes all the aggregate methods available to you when using Weaviate’s aggregation group-by capabilities.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

query_group_by

This namespace includes all the querying methods available to you when using Weaviate’s querying group-by capabilities.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

backup

This namespace includes all the backup methods available to you when backing up a collection in Weaviate.

batch

This namespace contains all the functionality to upload data in batches to Weaviate for this specific collection.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

exists() bool[source]

Check if the collection exists in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[Properties, References][source]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[Properties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[Properties, TReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[TProperties, References]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[TProperties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectIterator[TProperties, TReferences]

Use this method to return an iterator over the objects in the collection.

This iterator keeps a record of the last object that it returned to be used in each subsequent call to Weaviate. Once the collection is exhausted, the iterator exits.

If return_properties is not provided, all the properties of each object will be requested from Weaviate except for its vector as this is an expensive operation. Specify include_vector to request the vector back as well. In addition, if return_references=None then none of the references are returned. Use wvc.QueryReference to specify which references to return.

Arguments:
include_vector

Whether to include the vector in the metadata of the returned objects.

return_metadata

The metadata to return with each object.

return_properties

The properties to return with each object.

return_references

The references to return with each object.

after

The cursor to use to mark the initial starting point of the iterator in the collection.

cache_size

How many objects should be fetched in each request to Weaviate during the iteration. The default is 100.

Raises:
weaviate.exceptions.WeaviateGRPCQueryError:

If the request to the Weaviate server fails.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

shards() List[Shard][source]

Get the statuses of all the shards of this collection.

Returns:

The list of shards belonging to this collection.

Raises
weaviate.WeaviateConnectionError

If the network connection to weaviate fails.

weaviate.UnexpectedStatusCodeError

If weaviate reports a none OK status.

weaviate.EmptyResponseError

If the response is empty.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

with_consistency_level(consistency_level)
with_tenant(tenant)
class weaviate.collections.collection.CollectionAsync(connection: ConnectionV4, name: str, validate_arguments: bool, consistency_level: ConsistencyLevel | None = None, tenant: str | None = None, properties: Type[Properties] | None = None, references: Type[References] | None = None)[source]

Bases: Generic[Properties, References], _CollectionBase[Properties, References]

The collection class is the main entry point for interacting with a collection in Weaviate.

This class is returned by the client.collections.create and client.collections.get methods. It provides access to all the methods available to you when interacting with a collection in Weaviate.

You should not need to instantiate this class yourself but it may be useful to import this as a type when performing type hinting of functions that depend on a collection object.

Attributes:
aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

aggregate_group_by

This namespace includes all the aggregate methods available to you when using Weaviate’s aggregation group-by capabilities.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

query_group_by

This namespace includes all the querying methods available to you when using Weaviate’s querying group-by capabilities.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

aggregate

This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.

backup

This namespace includes all the backup methods available to you when backing up a collection in Weaviate.

config

This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.

data

This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.

async exists() bool[source]

Check if the collection exists in Weaviate.

generate

This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.

iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[Properties, References][source]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[Properties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Sequence[str | QueryNested] | str | QueryNested | None = None, return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[Properties, TReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Literal[None] = None, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[TProperties, References]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Sequence[_QueryReference | _QueryReferenceMultiTarget] | _QueryReference | _QueryReferenceMultiTarget, after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[TProperties, CrossReferences]
iterator(include_vector: bool = False, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None = None, *, return_properties: Type[TProperties], return_references: Type[TReferences], after: str | UUID | None = None, cache_size: int | None = None) _ObjectAIterator[TProperties, TReferences]

Use this method to return an iterator over the objects in the collection.

This iterator keeps a record of the last object that it returned to be used in each subsequent call to Weaviate. Once the collection is exhausted, the iterator exits.

If return_properties is not provided, all the properties of each object will be requested from Weaviate except for its vector as this is an expensive operation. Specify include_vector to request the vector back as well. In addition, if return_references=None then none of the references are returned. Use wvc.QueryReference to specify which references to return.

Arguments:
include_vector

Whether to include the vector in the metadata of the returned objects.

return_metadata

The metadata to return with each object.

return_properties

The properties to return with each object.

return_references

The references to return with each object.

after

The cursor to use to mark the initial starting point of the iterator in the collection.

cache_size

How many objects should be fetched in each request to Weaviate during the iteration. The default is 100.

Raises:
weaviate.exceptions.WeaviateGRPCQueryError:

If the request to the Weaviate server fails.

async length() int[source]

Get the total number of objects in the collection.

query

This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.

async shards() List[Shard][source]

Get the statuses of all the shards of this collection.

Returns:

The list of shards belonging to this collection.

Raises
weaviate.WeaviateConnectionError

If the network connection to weaviate fails.

weaviate.UnexpectedStatusCodeError

If weaviate reports a none OK status.

weaviate.EmptyResponseError

If the response is empty.

tenants

This namespace includes all the CRUD methods available to you when modifying the tenants of a multi-tenancy-enabled collection in Weaviate.

async to_string() str[source]

Return a string representation of the collection object.

with_consistency_level(consistency_level)
with_tenant(tenant)

weaviate.collections.collections module

weaviate.collections.config module

weaviate.collections.data module

weaviate.collections.filters module

weaviate.collections.iterator module

weaviate.collections.query module

weaviate.collections.tenants module

weaviate.collections.tenants.TenantOutputType

alias of Tenant