Query indexes

class couchbase.management.queries.CollectionQueryIndexManager(impl: QueryIndexMgmtInterface, bucket_name: str)

Performs management operations on query indexes at the collection level.

build_deferred_indexes(options: BuildDeferredQueryIndexOptions | None = None, **kwargs: Unpack[BuildDeferredQueryIndexOptionsKwargs]) → None

Starts building any indexes which were previously created with deferred=True.

Parameters:
  • options (BuildDeferredQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

create_index(index_name: str, keys: Iterable[str], options: CreateQueryIndexOptions | None = None, **kwargs: Unpack[CreateQueryIndexOptionsKwargs]) → None

Creates a new query index.

Parameters:
  • index_name (str) – The name of the index.

  • keys (Iterable[str]) – The keys which this index should cover.

  • options (CreateQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
create_primary_index(options: CreatePrimaryQueryIndexOptions | None = None, **kwargs: Unpack[CreatePrimaryQueryIndexOptionsKwargs]) → None

Creates a new primary query index.

Parameters:
  • options (CreatePrimaryQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:

QueryIndexAlreadyExistsException – If the index already exists.

drop_index(index_name: str, options: DropQueryIndexOptions | None = None, **kwargs: Unpack[DropQueryIndexOptionsKwargs]) → None

Drops an existing query index.

Parameters:
  • index_name (str) – The name of the index to drop.

  • options (DropQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
drop_primary_index(options: DropPrimaryQueryIndexOptions | None = None, **kwargs: Unpack[DropPrimaryQueryIndexOptionsKwargs]) → None

Drops an existing primary query index.

Parameters:
  • options (DropPrimaryQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:

QueryIndexNotFoundException – If the index does not exists.

get_all_indexes(options: GetAllQueryIndexOptions | None = None, **kwargs: Unpack[GetAllQueryIndexOptionsKwargs]) → Iterable[QueryIndex]

Returns a list of indexes for a specific collection.

Parameters:
  • options (GetAllQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of indexes.

Return type:

Iterable[QueryIndex]

watch_indexes(index_names: Iterable[str], options: WatchQueryIndexOptions | None = None, **kwargs: Unpack[WatchQueryIndexOptionsKwargs]) → None

Waits for a number of indexes to finish creation and be ready to use.

Parameters:
  • index_names (Iterable[str]) – The names of the indexes to watch.

  • options (WatchQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
class couchbase.management.queries.QueryIndex(name: str, is_primary: bool, type: str, state: str, namespace: str | None, datastore_id: str | None, keyspace: str | None, index_key: list[str] = <factory>, condition: str | None = None, bucket_name: str | None = None, scope_name: str | None = None, collection_name: str | None = None, partition: str | None = None)

A query index, as the query service describes it.

name

The name of the index.

Type:

str

is_primary

Whether the index is a primary index.

Type:

bool

type

The kind of index, such as gsi.

Type:

str

state

The state of the index, such as online or deferred.

Type:

str

namespace

The namespace the index is in, if the service reports it.

Type:

str | None

datastore_id

The datastore the index is in, if the service reports it.

Type:

str | None

keyspace

What the index is on: its collection, or its bucket for an index on the bucket itself.

Type:

str | None

index_key

The expressions the index keys on.

Type:

list[str]

condition

The WHERE clause of a partial index.

Type:

str | None

bucket_name

The name of the bucket the index is in.

Type:

str | None

scope_name

The name of the scope the index is in.

Type:

str | None

collection_name

The name of the collection the index is on.

Type:

str | None

partition

The PARTITION BY clause of a partitioned index.

Type:

str | None

class couchbase.management.queries.QueryIndexManager(impl: QueryIndexMgmtInterface)

Performs management operations on query indexes.

For managing query indexes at the collection level, CollectionQueryIndexManager should be used.

build_deferred_indexes(bucket_name: str, options: BuildDeferredQueryIndexOptions | None = None, **kwargs: Unpack[BuildDeferredQueryIndexOptionsKwargs]) → None

Starts building any indexes which were previously created with deferred=True.

Parameters:
  • bucket_name (str) – The name of the bucket to perform build on.

  • options (BuildDeferredQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:

InvalidArgumentException – If the bucket_name is an invalid type.

create_index(bucket_name: str, index_name: str, keys: Iterable[str], options: CreateQueryIndexOptions | None = None, **kwargs: Unpack[CreateQueryIndexOptionsKwargs]) → None

Creates a new query index.

Parameters:
  • bucket_name (str) – The name of the bucket this index is for.

  • index_name (str) – The name of the index.

  • keys (Iterable[str]) – The keys which this index should cover.

  • options (CreateQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
create_primary_index(bucket_name: str, options: CreatePrimaryQueryIndexOptions | None = None, **kwargs: Unpack[CreatePrimaryQueryIndexOptionsKwargs]) → None

Creates a new primary query index.

Parameters:
  • bucket_name (str) – The name of the bucket this index is for.

  • options (CreatePrimaryQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
drop_index(bucket_name: str, index_name: str, options: DropQueryIndexOptions | None = None, **kwargs: Unpack[DropQueryIndexOptionsKwargs]) → None

Drops an existing query index.

Parameters:
  • bucket_name (str) – The name of the bucket containing the index to drop.

  • index_name (str) – The name of the index to drop.

  • options (DropQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
drop_primary_index(bucket_name: str, options: DropPrimaryQueryIndexOptions | None = None, **kwargs: Unpack[DropPrimaryQueryIndexOptionsKwargs]) → None

Drops an existing primary query index.

Parameters:
  • bucket_name (str) – The name of the bucket this index to drop.

  • options (DropPrimaryQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises:
get_all_indexes(bucket_name: str, options: GetAllQueryIndexOptions | None = None, **kwargs: Unpack[GetAllQueryIndexOptionsKwargs]) → Iterable[QueryIndex]

Returns a list of indexes for a specific bucket.

Parameters:
  • bucket_name (str) – The name of the bucket to fetch indexes for.

  • options (GetAllQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of indexes for a specific bucket.

Return type:

Iterable[QueryIndex]

Raises:

InvalidArgumentException – If the bucket_name is an invalid type.

watch_indexes(bucket_name: str, index_names: Iterable[str], options: WatchQueryIndexOptions | None = None, **kwargs: Unpack[WatchQueryIndexOptionsKwargs]) → None

Waits for a number of indexes to finish creation and be ready to use.

Parameters:
  • bucket_name (str) – The name of the bucket to watch for indexes on.

  • index_names (Iterable[str]) – The names of the indexes to watch.

  • options (WatchQueryIndexOptions) – Optional parameters for this operation.

  • **kwargs – keyword arguments that can be used as optional parameters for this operation.

Raises: