Management

Note

Further updates to the management API docs will come with future 4.0.x releases.

Bucket Management

class couchbase.management.buckets.BucketManager(connection)
create_bucket(settings, *options, **kwargs) None

Creates a new bucket.

Parameters:
  • settings (CreateBucketSettings) – The settings to use for the new bucket.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • BucketAlreadyExistsException – If the bucket already exists.

  • InvalidArgumentsException – If an invalid type or value is provided for the settings argument.

drop_bucket(bucket_name, *options, **kwargs) None

Drops an existing bucket.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

BucketDoesNotExistException – If the bucket does not exist.

flush_bucket(bucket_name, *options, **kwargs) None

Flushes the bucket, deleting all the existing data that is stored in it.

Parameters:
  • bucket_name (str) – The name of the bucket to flush.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • BucketDoesNotExistException – If the bucket does not exist.

  • BucketNotFlushableException – If the bucket’s settings have flushing disabled.

get_all_buckets(*options, **kwargs) List[BucketSettings]

Returns a list of existing buckets in the cluster.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of existing buckets in the cluster.

Return type:

List[BucketSettings]

get_bucket(bucket_name, *options, **kwargs) BucketSettings

Fetches the settings in use for a specified bucket.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The settings of the specified bucket.

Return type:

BucketSettings

Raises:

BucketDoesNotExistException – If the bucket does not exist.

update_bucket(settings, *options, **kwargs) None

Update the settings for an existing bucket.

Parameters:
  • settings (BucketSettings) – The settings to use for the new bucket.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

InvalidArgumentsException – If an invalid type or value is provided for the settings argument.

Collection Management

class couchbase.management.collections.CollectionManager(connection, bucket_name)
create_collection(scope_name: str, collection_name: str, settings: CreateCollectionSettings | None = None, *options: CreateCollectionOptions, **kwargs: Dict[str, Any]) None

Creates a new collection in a specified scope.

Parameters:
  • scope_name (str) – The name of the scope the collection will be created in.

  • collection_name (str) – The name of the collection to be created

  • settings (CreateCollectionSettings, optional) – Settings to apply for the collection

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • CollectionAlreadyExistsException – If the collection already exists.

  • ScopeNotFoundException – If the scope does not exist.

create_collection(collection: CollectionSpec, *options: CreateCollectionOptions, **kwargs: Dict[str, Any]) None

Deprecated since version 4.1.9: Use create_collection(scope_name, collection_name, settings=None, *options, **kwargs) instead.

Creates a new collection in a specified scope.

Parameters:
  • collection (CollectionSpec) – The collection details.

  • *options (CreateCollectionOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • CollectionAlreadyExistsException – If the collection already exists.

  • ScopeNotFoundException – If the scope does not exist.

create_scope(scope_name: str, *options: CreateScopeOptions, **kwargs: Dict[str, Any]) None

Creates a new scope.

Parameters:
  • scope_name (str) – The name of the scope.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

ScopeAlreadyExistsException – If the scope already exists.

update_collection(scope_name: str, collection_name: str, settings: UpdateCollectionSettings, *options: UpdateCollectionOptions, **kwargs: Dict[str, Any]) None

Updates a collection in a specified scope.

Parameters:
  • scope_name (str) – The name of the scope the collection is in.

  • collection_name (str) – The name of the collection that will be updated

  • settings (UpdateCollectionSettings, optional) – Settings to apply for the collection

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • CollectionNotFoundException – If the collection does not exist.

  • ScopeNotFoundException – If the scope does not exist.

drop_collection(scope_name: str, collection_name: str, *options: DropCollectionOptions, **kwargs: Dict[str, Any]) None

Drops a collection from the specified scope.

Parameters:
  • scope_name (str) – The name of the scope the collection is in.

  • collection_name (str) – The name of the collection to be dropped

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

CollectionNotFoundException – If the collection does not exist.

drop_collection(collection: CollectionSpec, *options: DropCollectionOptions, **kwargs: Dict[str, Any]) None

Deprecated since version 4.1.9: Use drop_collection(scope_name, collection_name, *options, **kwargs) instead.

Drops a collection from a specified scope.

Parameters:
  • collection (CollectionSpec) – The collection details.

  • *options (DropCollectionOptions) – Optional parameters for this operation.

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

CollectionNotFoundException – If the collection does not exist.

drop_scope(scope_name: str, *options: DropScopeOptions, **kwargs: Dict[str, Any]) None

Drops an existing scope.

Parameters:
  • scope_name (str) – The name of the scope.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

ScopeNotFoundException – If the scope does not exist.

get_all_scopes(*options: GetAllScopesOptions, **kwargs: Dict[str, Any]) Iterable[ScopeSpec]

Returns all configured scopes along with their collections.

Parameters:
  • scope_name (str) – The name of the scope.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of all configured scopes.

Return type:

Iterable[ScopeSpec]

class couchbase.management.collections.CreateCollectionSettings(max_expiry=None, history=None)

Specifies settings for a collection that will be created.

property max_expiry: timedelta | None

The maximum expiry for documents in the collection.

Type:

Optional[timedelta]

property history: bool | None

Whether history retention override should be enabled in the collection. If not set, it will default to the bucket-level setting

Type:

Optional[bool]

class couchbase.management.collections.UpdateCollectionSettings(max_expiry=None, history=None)

Specifies settings for a collection that will be updated.

property max_expiry: timedelta | None

The maximum expiry for documents in the collection.

Type:

Optional[timedelta]

property history: bool | None

Whether history retention override should be enabled in the collection. If not set, it will default to the bucket-level setting

Type:

Optional[bool]

class couchbase.management.collections.CollectionSpec(collection_name, scope_name='_default', max_expiry=None, max_ttl=None, history=None)
property name: str

The name of the collection

Type:

str

property scope_name: str

The name of the collection’s scope

Type:

str

property max_expiry: timedelta | None

The expiry for documents in the collection.

Type:

Optional[timedelta]

property max_ttl: timedelta | None

The expiry for documents in the collection.

DEPRECATED Use max_expiry instead.

Type:

Optional[timedelta]

property history: bool | None

Whether history retention is enabled in the collection. None represents the bucket-level setting.

Type:

Optional[bool]

class couchbase.management.collections.ScopeSpec(name, collections)
property name: str

The name of the scope

Type:

str

property collections: Iterable[CollectionSpec]

A list of the scope’s collections.

Type:

List[CollectionSpec]

Query Index Management

class couchbase.management.queries.CollectionQueryIndexManager(connection, bucket_name, scope_name, collection_name)

Performs management operations on query indexes at the collection level.

build_deferred_indexes(*options, **kwargs) None

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

create_index(index_name, keys, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the index_name or keys are invalid types.

  • QueryIndexAlreadyExistsException – If the index already exists.

create_primary_index(*options, **kwargs) None

Creates a new primary query index.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

QueryIndexAlreadyExistsException – If the index already exists.

drop_index(index_name, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the index_name is an invalid types.

  • QueryIndexNotFoundException – If the index does not exists.

drop_primary_index(*options, **kwargs) None

Drops an existing primary query index.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

QueryIndexNotFoundException – If the index does not exists.

get_all_indexes(*options, **kwargs) Iterable[QueryIndex]

Returns a list of indexes for a specific collection.

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

  • **kwargs (Dict[str, Any]) – 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, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the index_names are invalid types.

  • WatchQueryIndexTimeoutException – If the specified timeout is reached before all the specified indexes are ready to use.

class couchbase.management.queries.QueryIndexManager(connection)

Performs management operations on query indexes.

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

build_deferred_indexes(bucket_name, *options, **kwargs) 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 (Dict[str, Any]) – 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, index_name, keys, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the bucket_name, index_name or keys are invalid types.

  • QueryIndexAlreadyExistsException – If the index already exists.

create_primary_index(bucket_name, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the bucket_name is an invalid type.

  • QueryIndexAlreadyExistsException – If the index already exists.

drop_index(bucket_name, index_name, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the bucket_name or index_name are invalid types.

  • QueryIndexNotFoundException – If the index does not exists.

drop_primary_index(bucket_name, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the bucket_name is an invalid type.

  • QueryIndexNotFoundException – If the index does not exists.

get_all_indexes(bucket_name, *options, **kwargs) 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 (Dict[str, Any]) – 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, index_names, *options, **kwargs) 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 (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:
  • InvalidArgumentException – If the bucket_name or index_names are invalid types.

  • WatchQueryIndexTimeoutException – If the specified timeout is reached before all the specified indexes are ready to use.

User Management

class couchbase.management.users.UserManager(connection)
drop_user(username, *options, **kwargs) None

Drops an existing user.

Parameters:
  • username (str) – The name of the user to drop.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

UserNotFoundException – If the user does not exist.

drop_group(group_name, *options, **kwargs) None

Drops an existing group.

Parameters:
  • group_name (str) – The name of the group to drop.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

GroupNotFoundException – If the group does not exist.

get_all_groups(*options, **kwargs) Iterable[Group]

Returns a list of all existing groups.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of existing groups.

Return type:

Iterable[Group]

get_all_users(*options, **kwargs) Iterable[UserAndMetadata]

Returns a list of all existing users.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of existing users.

Return type:

Iterable[UserAndMetadata]

get_group(group_name, *options, **kwargs) Group

Returns a group by it’s name.

Parameters:
  • group_name (str) – The name of the group to retrieve.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A Group instance.

Return type:

Group

Raises:

GroupNotFoundException – If the group does not exist.

get_roles(*options, **kwargs) Iterable[RoleAndDescription]

Returns a list of roles available on the server.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of roles available on the server.

Return type:

Iterable[RoleAndDescription]

get_user(username, *options, **kwargs) UserAndMetadata

Returns a user by its username.

Parameters:
  • username (str) – The name of the user to retrieve.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A UserAndMetadata instance.

Return type:

UserAndMetadata

Raises:

UserNotFoundException – If the user does not exist.

upsert_group(group, *options, **kwargs) None

Creates a new group or updates an existing group.

Parameters:
  • group (Group) – The group to create or update.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

InvalidArgumentException – If the provided group argument contains an invalid value or type.

upsert_user(user, *options, **kwargs) None

Creates a new user or updates an existing user.

Parameters:
  • user (User) – The user to create or update.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

InvalidArgumentException – If the provided user argument contains an invalid value or type.

Search Index Management

class couchbase.management.search.ScopeSearchIndexManager(connection, bucket_name, scope_name)

Allows to manage scope-level search indexes in a Couchbase cluster.

upsert_index(index, *options, **kwargs) None

Creates or updates an index.

Parameters:
  • index (SearchIndex) – The index definition.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

InvalidArgumentException – If the index definition is invalid.

drop_index(index_name, *options, **kwargs) None

Drops an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_index(index_name, *options, **kwargs) SearchIndex

Fetches an index from the server if it exists.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The index definition if it exists.

Return type:

SearchIndex

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_all_indexes(*options, **kwargs) Iterable[SearchIndex]

Fetches all indexes from the server.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of all indexes.

Return type:

Iterable[SearchIndex]

get_indexed_documents_count(index_name, *options, **kwargs) int

Retrieves the number of documents that have been indexed for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The number of documents indexed for the specified index.

Return type:

int

Raises:

SearchIndexNotFoundException – If the index does not exist.

pause_ingest(index_name, *options, **kwargs) None

Pauses updates and maintenance for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

resume_ingest(index_name, *options, **kwargs) None

Resumes updates and maintenance for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

allow_querying(index_name, *options, **kwargs) None

Allows querying against an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

disallow_querying(index_name, *options, **kwargs) None

Disallows querying against an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

freeze_plan(index_name, *options, **kwargs) None

Freezes the assignment of index partitions to nodes for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

unfreeze_plan(index_name, *options, **kwargs) None

Unfreezes the assignment of index partitions to nodes for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

analyze_document(index_name, document, *options, **kwargs) Dict[str, Any]

Allows to see how a document is analyzed against a specific index.

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

  • document (Any) – The document to analyze.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The analyzed sections for the document.

Return type:

Dict[str, Any]

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_index_stats(index_name, *options, **kwargs) Dict[str, Any]

Retrieves metrics, timings and counters for a given index.

Note

UNCOMMITTED: This is an uncommitted API call that is unlikely to change, but may still change as final consensus on its behavior has not yet been reached.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The stats for the index.

Return type:

Dict[str, Any]

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_all_index_stats(*options, **kwargs) Dict[str, Any]

Retrieves statistics on search service. Information is provided on documents, partition indexes, mutations, compactions, queries, and more.

Note

UNCOMMITTED: This is an uncommitted API call that is unlikely to change, but may still change as final consensus on its behavior has not yet been reached.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The stats report.

Return type:

Dict[str, Any]

class couchbase.management.search.SearchIndexManager(connection)

Allows to manage search indexes in a Couchbase cluster.

upsert_index(index, *options, **kwargs) None

Creates or updates an index.

Parameters:
  • index (SearchIndex) – The index definition.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

InvalidArgumentException – If the index definition is invalid.

drop_index(index_name, *options, **kwargs) None

Drops an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_index(index_name, *options, **kwargs) SearchIndex

Fetches an index from the server if it exists.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The index definition if it exists.

Return type:

SearchIndex

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_all_indexes(*options, **kwargs) Iterable[SearchIndex]

Fetches all indexes from the server.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

A list of all indexes.

Return type:

Iterable[SearchIndex]

get_indexed_documents_count(index_name, *options, **kwargs) int

Retrieves the number of documents that have been indexed for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The number of documents indexed for the specified index.

Return type:

int

Raises:

SearchIndexNotFoundException – If the index does not exist.

pause_ingest(index_name, *options, **kwargs) None

Pauses updates and maintenance for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

resume_ingest(index_name, *options, **kwargs) None

Resumes updates and maintenance for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

allow_querying(index_name, *options, **kwargs) None

Allows querying against an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

disallow_querying(index_name, *options, **kwargs) None

Disallows querying against an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

freeze_plan(index_name, *options, **kwargs) None

Freezes the assignment of index partitions to nodes for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

unfreeze_plan(index_name, *options, **kwargs) None

Unfreezes the assignment of index partitions to nodes for an index.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

analyze_document(index_name, document, *options, **kwargs) Dict[str, Any]

Allows to see how a document is analyzed against a specific index.

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

  • document (Any) – The document to analyze.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The analyzed sections for the document.

Return type:

Dict[str, Any]

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_index_stats(index_name, *options, **kwargs) Dict[str, Any]

Retrieves metrics, timings and counters for a given index.

UNCOMMITTED This is an uncommitted API call that is unlikely to change, but may still change as final consensus on its behavior has not yet been reached.

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

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The stats for the index.

Return type:

Dict[str, Any]

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_all_index_stats(*options, **kwargs) Dict[str, Any]

Retrieves statistics on search service. Information is provided on documents, partition indexes, mutations, compactions, queries, and more.

UNCOMMITTED This is an uncommitted API call that is unlikely to change, but may still change as final consensus on its behavior has not yet been reached.

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

  • **kwargs (Dict[str, Any]) – keyword arguments that can be used as optional parameters for this operation.

Returns:

The stats report.

Return type:

Dict[str, Any]

class couchbase.management.search.SearchIndex(name: str, source_type: str = 'couchbase', idx_type: str = 'fulltext-index', source_name: str | None = None, uuid: str | None = None, params: dict = <factory>, source_uuid: str | None = None, source_params: dict = <factory>, plan_params: dict = <factory>)

Object representation for a Couchbase search index.

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

  • source_type (str, optional) – Type of the data source.

  • idx_type (str, optional) – Type of the index.

  • source_name (str) – Name of the source of the data for the index (e.g. bucket name).

  • uuid (str, optional) – UUID of the index. It must be specified for an update.

  • params (dict, optional) – Index properties such as store type and mappings

  • source_uuid (str, optional) – The UUID of the data source, this can be used to more tightly tie the index to a source.

  • source_params (dict, optional) – Extra parameters for the source. These can include advanced connection settings and tuning.

  • plan_params (dict, optional) – Plan properties such as number of replicas and number of partitions.

classmethod from_json(json_input) SearchIndex

Creates a SearchIndex from a provided JSON str or Python dict derived from JSON.

Parameters:

json_input (Union[str, Dict[str, Any]]) – JSON representation of the search index.

Raises: