Search indexes

class couchbase.management.search.ScopeSearchIndexManager(impl: SearchIndexMgmtInterface)

Performs management operations on the search indexes of a scope.

allow_querying(index_name: str, options: AllowQueryingSearchIndexOptions | None = None, **kwargs: Unpack[AllowQueryingSearchIndexOptionsKwargs]) → None

Allows querying against an index.

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

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

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

Raises:

SearchIndexNotFoundException – If the index does not exist.

analyze_document(index_name: str, document: Any, options: AnalyzeDocumentSearchIndexOptions | None = None, **kwargs: Unpack[AnalyzeDocumentSearchIndexOptionsKwargs]) → 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 – 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.

disallow_querying(index_name: str, options: DisallowQueryingSearchIndexOptions | None = None, **kwargs: Unpack[DisallowQueryingSearchIndexOptionsKwargs]) → None

Disallows querying against an index.

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

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

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

Raises:

SearchIndexNotFoundException – If the index does not exist.

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

Drops an index.

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

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

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

Raises:

SearchIndexNotFoundException – If the index does not exist.

freeze_plan(index_name: str, options: FreezePlanSearchIndexOptions | None = None, **kwargs: Unpack[FreezePlanSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_all_index_stats(options: GetAllSearchIndexStatsOptions | None = None, **kwargs: Unpack[GetAllSearchIndexStatsOptionsKwargs]) → dict[str, Any]

Retrieves statistics on the search service.

The statistics cover 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 – keyword arguments that can be used as optional parameters for this operation.

Returns:

The stats report.

Return type:

dict[str, Any]

get_all_indexes(options: GetAllSearchIndexesOptions | None = None, **kwargs: Unpack[GetAllSearchIndexesOptionsKwargs]) → Iterable[SearchIndex]

Fetches all indexes from the server.

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

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

Returns:

A list of all indexes.

Return type:

Iterable[SearchIndex]

get_index(index_name: str, options: GetSearchIndexOptions | None = None, **kwargs: Unpack[GetSearchIndexOptionsKwargs]) → 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 – 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_index_stats(index_name: str, options: GetSearchIndexStatsOptions | None = None, **kwargs: Unpack[GetSearchIndexStatsOptionsKwargs]) → 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 – 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_indexed_documents_count(index_name: str, options: GetSearchIndexedDocumentsCountOptions | None = None, **kwargs: Unpack[GetSearchIndexedDocumentsCountOptionsKwargs]) → 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 – 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: str, options: PauseIngestSearchIndexOptions | None = None, **kwargs: Unpack[PauseIngestSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

resume_ingest(index_name: str, options: ResumeIngestSearchIndexOptions | None = None, **kwargs: Unpack[ResumeIngestSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

unfreeze_plan(index_name: str, options: UnfreezePlanSearchIndexOptions | None = None, **kwargs: Unpack[UnfreezePlanSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

upsert_index(index: SearchIndex, options: UpsertSearchIndexOptions | None = None, **kwargs: Unpack[UpsertSearchIndexOptionsKwargs]) → None

Creates or updates an index.

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

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

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

Raises:

InvalidArgumentException – If the index definition is invalid.

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[str, ~typing.Any] = <factory>, source_uuid: str | None = None, source_params: dict[str, ~typing.Any] = <factory>, plan_params: dict[str, ~typing.Any] = <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: str | dict[str, Any]) → SearchIndex

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

Parameters:

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

Raises:
is_valid() → bool

Check that the index has a name, a type and a source type.

Returns:

True if none of the three is empty.

Return type:

bool

class couchbase.management.search.SearchIndexManager(impl: SearchIndexMgmtInterface)

Performs management operations on search indexes.

For managing the search indexes of a scope, ScopeSearchIndexManager should be used.

allow_querying(index_name: str, options: AllowQueryingSearchIndexOptions | None = None, **kwargs: Unpack[AllowQueryingSearchIndexOptionsKwargs]) → None

Allows querying against an index.

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

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

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

Raises:

SearchIndexNotFoundException – If the index does not exist.

analyze_document(index_name: str, document: Any, options: AnalyzeDocumentSearchIndexOptions | None = None, **kwargs: Unpack[AnalyzeDocumentSearchIndexOptionsKwargs]) → 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 – 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.

disallow_querying(index_name: str, options: DisallowQueryingSearchIndexOptions | None = None, **kwargs: Unpack[DisallowQueryingSearchIndexOptionsKwargs]) → None

Disallows querying against an index.

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

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

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

Raises:

SearchIndexNotFoundException – If the index does not exist.

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

Drops an index.

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

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

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

Raises:

SearchIndexNotFoundException – If the index does not exist.

freeze_plan(index_name: str, options: FreezePlanSearchIndexOptions | None = None, **kwargs: Unpack[FreezePlanSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

get_all_index_stats(options: GetAllSearchIndexStatsOptions | None = None, **kwargs: Unpack[GetAllSearchIndexStatsOptionsKwargs]) → dict[str, Any]

Retrieves statistics on the search service.

The statistics cover 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 – keyword arguments that can be used as optional parameters for this operation.

Returns:

The stats report.

Return type:

dict[str, Any]

get_all_indexes(options: GetAllSearchIndexesOptions | None = None, **kwargs: Unpack[GetAllSearchIndexesOptionsKwargs]) → Iterable[SearchIndex]

Fetches all indexes from the server.

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

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

Returns:

A list of all indexes.

Return type:

Iterable[SearchIndex]

get_index(index_name: str, options: GetSearchIndexOptions | None = None, **kwargs: Unpack[GetSearchIndexOptionsKwargs]) → 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 – 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_index_stats(index_name: str, options: GetSearchIndexStatsOptions | None = None, **kwargs: Unpack[GetSearchIndexStatsOptionsKwargs]) → 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 – 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_indexed_documents_count(index_name: str, options: GetSearchIndexedDocumentsCountOptions | None = None, **kwargs: Unpack[GetSearchIndexedDocumentsCountOptionsKwargs]) → 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 – 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: str, options: PauseIngestSearchIndexOptions | None = None, **kwargs: Unpack[PauseIngestSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

resume_ingest(index_name: str, options: ResumeIngestSearchIndexOptions | None = None, **kwargs: Unpack[ResumeIngestSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

unfreeze_plan(index_name: str, options: UnfreezePlanSearchIndexOptions | None = None, **kwargs: Unpack[UnfreezePlanSearchIndexOptionsKwargs]) → 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 – keyword arguments that can be used as optional parameters for this operation.

Raises:

SearchIndexNotFoundException – If the index does not exist.

upsert_index(index: SearchIndex, options: UpsertSearchIndexOptions | None = None, **kwargs: Unpack[UpsertSearchIndexOptionsKwargs]) → None

Creates or updates an index.

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

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

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

Raises:

InvalidArgumentException – If the index definition is invalid.