weaviate.collections

class weaviate.collections.Collection(connection, name, validate_arguments, consistency_level=None, tenant=None, properties=None, references=None)[source]

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.

exists()[source]

Check if the collection exists in Weaviate.

Return type:

bool

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:
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:

Collection[Properties, References]

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:

Collection[Properties, References]

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.

tenants: _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.CollectionAsync(connection, name, validate_arguments, consistency_level=None, tenant=None, properties=None, references=None)[source]

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.

async exists()[source]

Check if the collection exists in Weaviate.

Return type:

bool

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 length()[source]

Get the total number of objects in the collection.

Return type:

int

async shards()[source]

Get the statuses of all the shards of this collection.

Returns:

The list of shards belonging to this collection.

Raises:
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:

CollectionAsync[Properties, References]

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:

CollectionAsync[Properties, References]

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.

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: _GenerateCollectionAsync[Properties, References]

This namespace includes all the querying methods available to you when using Weaviate’s generative 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.

Subpackages

weaviate.collections.aggregate

class weaviate.collections.aggregate._AggregateCollectionAsync(connection, name, consistency_level, tenant, validate_arguments)[source]

Bases: _HybridAsync, _NearImageAsync, _NearObjectAsync, _NearTextAsync, _NearVectorAsync, _OverAllAsync

Parameters:
  • connection (ConnectionType)

  • name (str)

  • consistency_level (ConsistencyLevel | None)

  • tenant (str | None)

  • validate_arguments (bool)

class weaviate.collections.aggregate._AggregateCollection(connection, name, consistency_level, tenant, validate_arguments)[source]

Bases: _Hybrid, _NearImage, _NearObject, _NearText, _NearVector, _OverAll

Parameters:
  • connection (ConnectionType)

  • name (str)

  • consistency_level (ConsistencyLevel | None)

  • tenant (str | None)

  • validate_arguments (bool)

weaviate.collections.filters

class weaviate.collections.filters._FilterToGRPC[source]

Bases: object

static convert(weav_filter: Literal[None]) None[source]
static convert(weav_filter: _Filters) Filters
static _FilterToGRPC__and_or_filter(weav_filter)
Parameters:

weav_filter (_Filters)

Return type:

Filters | None

static _FilterToGRPC__filter_to_bool_list(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

BooleanArray | None

static _FilterToGRPC__filter_to_float_list(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

NumberArray | None

static _FilterToGRPC__filter_to_geo(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

GeoCoordinatesFilter | None

static _FilterToGRPC__filter_to_int_list(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

IntArray | None

static _FilterToGRPC__filter_to_text(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

str | None

static _FilterToGRPC__filter_to_text_list(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

TextArray | None

static _FilterToGRPC__to_target(target)
Parameters:

target (_SingleTargetRef | _MultiTargetRef | _CountRef | str)

Return type:

FilterTarget

static _FilterToGRPC__value_filter(weav_filter)
Parameters:

weav_filter (_FilterValue)

Return type:

Filters

class weaviate.collections.filters._FilterToREST[source]

Bases: object

static convert(weav_filter)[source]
Parameters:

weav_filter (_Filters)

Return type:

Dict[str, Any]

static _FilterToREST__and_or_filter(weav_filter)
Parameters:

weav_filter (_Filters)

Return type:

Dict[str, Any]

static _FilterToREST__parse_filter(value)
Parameters:

value (int | float | str | bool | datetime | UUID | _GeoCoordinateFilter | None | Sequence[str] | Sequence[bool] | Sequence[int] | Sequence[float] | Sequence[datetime] | Sequence[str | UUID])

Return type:

Dict[str, Any]

static _FilterToREST__to_path(target)
Parameters:

target (_SingleTargetRef | _MultiTargetRef | _CountRef | str)

Return type:

List[str]

static _FilterToREST__value_filter(weav_filter)
Parameters:

weav_filter (_FilterValue)

Return type:

Dict[str, Any]

weaviate.collections.generate

class weaviate.collections.generate._GenerateCollectionAsync(connection, name, consistency_level, tenant, properties, references, validate_arguments)[source]

Bases: Generic[TProperties, References], _BM25GenerateAsync[TProperties, References], _FetchObjectsGenerateAsync[TProperties, References], _FetchObjectsByIDsGenerateAsync[TProperties, References], _HybridGenerateAsync[TProperties, References], _NearImageGenerateAsync[TProperties, References], _NearMediaGenerateAsync[TProperties, References], _NearObjectGenerateAsync[TProperties, References], _NearTextGenerateAsync[TProperties, References], _NearVectorGenerateAsync[TProperties, References]

Parameters:
  • connection (ConnectionType)

  • name (str)

  • consistency_level (ConsistencyLevel | None)

  • tenant (str | None)

  • properties (Type[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]]]] | None)

  • references (Type[Mapping[str, Any] | None] | None)

  • validate_arguments (bool)

class weaviate.collections.generate._GenerateCollection(connection, name, consistency_level, tenant, properties, references, validate_arguments)[source]

Bases: Generic[TProperties, References], _BM25Generate[TProperties, References], _FetchObjectsGenerate[TProperties, References], _FetchObjectsByIDsGenerate[TProperties, References], _HybridGenerate[TProperties, References], _NearImageGenerate[TProperties, References], _NearMediaGenerate[TProperties, References], _NearObjectGenerate[TProperties, References], _NearTextGenerate[TProperties, References], _NearVectorGenerate[TProperties, References]

Parameters:
  • connection (ConnectionType)

  • name (str)

  • consistency_level (ConsistencyLevel | None)

  • tenant (str | None)

  • properties (Type[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]]]] | None)

  • references (Type[Mapping[str, Any] | None] | None)

  • validate_arguments (bool)

weaviate.collections.iterator

class weaviate.collections.iterator._IteratorInputs(include_vector: bool, return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | weaviate.collections.classes.grpc.MetadataQuery | NoneType, return_properties: Sequence[str | weaviate.collections.classes.grpc.QueryNested] | str | weaviate.collections.classes.grpc.QueryNested | bool | Type[TProperties] | NoneType, return_references: weaviate.collections.classes.grpc._QueryReference | Sequence[weaviate.collections.classes.grpc._QueryReference] | Type[TReferences] | NoneType, after: str | uuid.UUID | NoneType)[source]

Bases: Generic[TProperties, TReferences]

Parameters:
  • include_vector (bool)

  • return_metadata (List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | ~weaviate.collections.classes.grpc.MetadataQuery | None)

  • return_properties (Sequence[str | QueryNested] | str | QueryNested | bool | Type[TProperties] | None)

  • return_references (_QueryReference | Sequence[_QueryReference] | Type[TReferences] | None)

  • after (str | UUID | None)

include_vector: bool
return_metadata: List[Literal['creation_time', 'last_update_time', 'distance', 'certainty', 'score', 'explain_score', 'is_consistent']] | MetadataQuery | None
return_properties: Sequence[str | QueryNested] | str | QueryNested | bool | Type[TProperties] | None
return_references: _QueryReference | Sequence[_QueryReference] | Type[TReferences] | None
after: str | UUID | None
weaviate.collections.iterator._parse_after(after)[source]
Parameters:

after (str | UUID | None)

Return type:

UUID | None

class weaviate.collections.iterator._ObjectIterator(query, inputs, cache_size=None)[source]

Bases: Generic[TProperties, TReferences], Iterable[Object[TProperties, TReferences]]

Parameters:
_abc_impl = <_abc._abc_data object>
class weaviate.collections.iterator._ObjectAIterator(query, inputs, cache_size=None)[source]

Bases: Generic[TProperties, TReferences], AsyncIterable[Object[TProperties, TReferences]]

Parameters:
_abc_impl = <_abc._abc_data object>

weaviate.collections.orm

weaviate.collections.query

class weaviate.collections.query._QueryCollectionAsync(connection, name, consistency_level, tenant, properties, references, validate_arguments)[source]

Bases: Generic[TProperties, References], _BM25QueryAsync[TProperties, References], _FetchObjectByIDQueryAsync[TProperties, References], _FetchObjectsByIDsQueryAsync[TProperties, References], _FetchObjectsQueryAsync[TProperties, References], _HybridQueryAsync[TProperties, References], _NearImageQueryAsync[TProperties, References], _NearMediaQueryAsync[TProperties, References], _NearObjectQueryAsync[TProperties, References], _NearTextQueryAsync[TProperties, References], _NearVectorQueryAsync[TProperties, References]

Parameters:
  • connection (ConnectionType)

  • name (str)

  • consistency_level (ConsistencyLevel | None)

  • tenant (str | None)

  • properties (Type[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]]]] | None)

  • references (Type[Mapping[str, Any] | None] | None)

  • validate_arguments (bool)

class weaviate.collections.query._QueryCollection(connection, name, consistency_level, tenant, properties, references, validate_arguments)[source]

Bases: Generic[TProperties, References], _BM25Query[TProperties, References], _FetchObjectByIDQuery[TProperties, References], _FetchObjectsByIDsQuery[TProperties, References], _FetchObjectsQuery[TProperties, References], _HybridQuery[TProperties, References], _NearImageQuery[TProperties, References], _NearMediaQuery[TProperties, References], _NearObjectQuery[TProperties, References], _NearTextQuery[TProperties, References], _NearVectorQuery[TProperties, References]

Parameters:
  • connection (ConnectionType)

  • name (str)

  • consistency_level (ConsistencyLevel | None)

  • tenant (str | None)

  • properties (Type[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]]]] | None)

  • references (Type[Mapping[str, Any] | None] | None)

  • validate_arguments (bool)