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: _CollectionBase, Generic[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.

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) _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) _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) _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) _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) _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) _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.

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.

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: ConsistencyLevel | None = None) Collection[Properties, References][source]

Use this method to return a collection object specific to a single consistency level.

If replication is not configured for this collection then Weaviate will throw an error.

This method does not send a request to Weaviate. It only returns a new collection object that is specific to the consistency level you specify.

Arguments:
consistency_level

The consistency level to use.

with_tenant(tenant: str | Tenant | None = None) Collection[Properties, References][source]

Use this method to return a collection object specific to a single tenant.

If multi-tenancy is not configured for this collection then Weaviate will throw an error.

This method does not send a request to Weaviate. It only returns a new collection object that is specific to the tenant you specify.

Arguments:
tenant

The tenant to use. Can be str or wvc.tenants.Tenant.

Subpackages

Submodules

weaviate.collections.aggregate module

weaviate.collections.base 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: _CollectionBase, Generic[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.

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) _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) _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) _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) _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) _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) _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.

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.

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: ConsistencyLevel | None = None) Collection[Properties, References][source]

Use this method to return a collection object specific to a single consistency level.

If replication is not configured for this collection then Weaviate will throw an error.

This method does not send a request to Weaviate. It only returns a new collection object that is specific to the consistency level you specify.

Arguments:
consistency_level

The consistency level to use.

with_tenant(tenant: str | Tenant | None = None) Collection[Properties, References][source]

Use this method to return a collection object specific to a single tenant.

If multi-tenancy is not configured for this collection then Weaviate will throw an error.

This method does not send a request to Weaviate. It only returns a new collection object that is specific to the tenant you specify.

Arguments:
tenant

The tenant to use. Can be str or wvc.tenants.Tenant.

weaviate.collections.collections module

weaviate.collections.config module

weaviate.collections.data module

weaviate.collections.filters module

weaviate.collections.iterator module

weaviate.collections.orm module

weaviate.collections.query module

weaviate.collections.tenants module