weaviate.collections.collection
- class weaviate.collections.collection.CollectionAsync(connection, name, validate_arguments, consistency_level=None, tenant=None, properties=None, references=None)[source]
Bases:
Generic
[Properties
,References
],_CollectionBase
[ConnectionAsync
]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.
- Parameters:
connection (ConnectionAsync)
name (str)
validate_arguments (bool)
consistency_level (ConsistencyLevel | None)
tenant (str | None)
properties (Type[Properties] | None)
references (Type[References] | None)
- 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.
- iterator(include_vector=False, return_metadata=None, *, return_properties=None, return_references=None, after=None, cache_size=None)[source]
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.
- Parameters:
include_vector (bool) – Whether to include the vector in the metadata of the returned objects.
return_metadata (List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | ~weaviate.collections.classes.grpc.MetadataQuery | None) – The metadata to return with each object.
return_properties (Sequence[str | QueryNested] | str | QueryNested | bool | Type[TProperties] | None) – The properties to return with each object.
return_references (_QueryReference | Sequence[_QueryReference] | Type[TReferences] | None) – The references to return with each object.
after (str | UUID | None) – The cursor to use to mark the initial starting point of the iterator in the collection.
cache_size (int | None) – How many objects should be fetched in each request to Weaviate during the iteration. The default is 100.
- Raises:
WeaviateGRPCQueryError – If the request to the Weaviate server fails.
- Return type:
_ObjectAIterator[Properties, References] | _ObjectAIterator[Properties, Mapping[str, _CrossReference[Mapping[str, None | str | bool | int | float | datetime | UUID | GeoCoordinate | PhoneNumber | _PhoneNumber | Mapping[str, WeaviateField] | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[UUID] | Sequence[Mapping[str, WeaviateField]]], CrossReferences]]] | _ObjectAIterator[Properties, TReferences] | _ObjectAIterator[TProperties, References] | _ObjectAIterator[TProperties, Mapping[str, _CrossReference[Mapping[str, None | str | bool | int | float | datetime | UUID | GeoCoordinate | PhoneNumber | _PhoneNumber | Mapping[str, WeaviateField] | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[UUID] | Sequence[Mapping[str, WeaviateField]]], CrossReferences]]] | _ObjectAIterator[TProperties, TReferences]
- async shards()[source]
Get the statuses of all the shards of this collection.
- Returns:
The list of shards belonging to this collection.
- Raises:
WeaviateConnectionError – If the network connection to weaviate fails.
UnexpectedStatusCodeError – If weaviate reports a none OK status.
weaviate.EmptyResponseError – If the response is empty.
- Return type:
List[Shard]
- async to_string()[source]
Return a string representation of the collection object.
- Return type:
str
- with_consistency_level(consistency_level)[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.
- Parameters:
consistency_level (ConsistencyLevel | None) – The consistency level to use.
- Return type:
- with_tenant(tenant)[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.
- Parameters:
tenant (str | Tenant | None) – The tenant to use. Can be str or wvc.tenants.Tenant.
- Return type:
- aggregate: _AggregateCollectionAsync
This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.
- backup: _CollectionBackupAsync
This namespace includes all the backup methods available to you when backing up a collection in Weaviate.
- generate: _GenerateCollectionAsync[Properties, References]
This namespace includes all the querying methods available to you when using Weaviate’s generative 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.
- 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.
- class weaviate.collections.collection.Collection(connection, name, validate_arguments, consistency_level=None, tenant=None, properties=None, references=None)[source]
Bases:
Generic
[Properties
,References
],_CollectionBase
[ConnectionSync
]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.
- Parameters:
connection (ConnectionSync)
name (str)
validate_arguments (bool)
consistency_level (ConsistencyLevel | None)
tenant (str | None)
properties (Type[Properties] | None)
references (Type[References] | None)
- 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.
- iterator(include_vector=False, return_metadata=None, *, return_properties=None, return_references=None, after=None, cache_size=None)[source]
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.
- Parameters:
include_vector (bool) – Whether to include the vector in the metadata of the returned objects.
return_metadata (List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | ~weaviate.collections.classes.grpc.MetadataQuery | None) – The metadata to return with each object.
return_properties (Sequence[str | QueryNested] | str | QueryNested | bool | Type[TProperties] | None) – The properties to return with each object.
return_references (_QueryReference | Sequence[_QueryReference] | Type[TReferences] | None) – The references to return with each object.
after (str | UUID | None) – The cursor to use to mark the initial starting point of the iterator in the collection.
cache_size (int | None) – How many objects should be fetched in each request to Weaviate during the iteration. The default is 100.
- Raises:
WeaviateGRPCQueryError – If the request to the Weaviate server fails.
- Return type:
_ObjectIterator[Properties, References] | _ObjectIterator[Properties, Mapping[str, _CrossReference[Mapping[str, None | str | bool | int | float | datetime | UUID | GeoCoordinate | PhoneNumber | _PhoneNumber | Mapping[str, WeaviateField] | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[UUID] | Sequence[Mapping[str, WeaviateField]]], CrossReferences]]] | _ObjectIterator[Properties, TReferences] | _ObjectIterator[TProperties, References] | _ObjectIterator[TProperties, Mapping[str, _CrossReference[Mapping[str, None | str | bool | int | float | datetime | UUID | GeoCoordinate | PhoneNumber | _PhoneNumber | Mapping[str, WeaviateField] | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[UUID] | Sequence[Mapping[str, WeaviateField]]], CrossReferences]]] | _ObjectIterator[TProperties, TReferences]
- shards()[source]
Get the statuses of all the shards of this collection.
- Returns:
The list of shards belonging to this collection.
- Raises:
WeaviateConnectionError – If the network connection to weaviate fails.
UnexpectedStatusCodeError – If weaviate reports a none OK status.
weaviate.EmptyResponseError – If the response is empty.
- Return type:
List[Shard]
- with_consistency_level(consistency_level)[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.
- Parameters:
consistency_level (ConsistencyLevel) – The consistency level to use.
- Return type:
- with_tenant(tenant)[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.
- Parameters:
tenant (str | Tenant) – The tenant to use. Can be str or wvc.tenants.Tenant.
- Return type:
- aggregate: _AggregateCollection
This namespace includes all the querying methods available to you when using Weaviate’s standard aggregation capabilities.
- backup: _CollectionBackup
This namespace includes all the backup methods available to you when backing up a collection in Weaviate.
- batch: _BatchCollectionWrapper[Properties]
This namespace contains all the functionality to upload data in batches to Weaviate for this specific collection.
- config: _ConfigCollection
This namespace includes all the CRUD methods available to you when modifying the configuration of the collection in Weaviate.
- data: _DataCollection[Properties]
This namespace includes all the CUD methods available to you when modifying the data of the collection in Weaviate.
- generate: _GenerateCollection[Properties, References]
This namespace includes all the querying methods available to you when using Weaviate’s generative capabilities.
- query: _QueryCollection[Properties, References]
This namespace includes all the querying methods available to you when using Weaviate’s standard query capabilities.