Scope
- class txcouchbase.scope.Scope(bucket: Bucket, scope_name: str)
A scope in a bucket: its collections, and the queries and searches run against it.
Get one from
scope().- Parameters:
- analytics_query(statement: str, *options: AnalyticsOptions | str | int | float | bool | None | Mapping[str, Any] | Sequence[Any], **kwargs: Any) Deferred[AnalyticsResult]
Executes an analaytics query against the scope.
Note
The analytics query is sent when this is called, and the Deferred fires once the core has buffered the response, so iterating the
AnalyticsResultdoes not block the reactor.See also
AnalyticsIndexManager: for how to manage analytics dataverses, datasets, indexes and links.analytics_query(): for how to execute cluster-level analytics queries
- Parameters:
statement (str) – The analytics SQL++ statement to execute.
options (
AnalyticsOptions) – Optional parameters for the analytics query operation.**kwargs – keyword arguments that can be used in place or to override provided
AnalyticsOptions. A keyword that is not one of its options is sent as a named parameter; preferAnalyticsOptions(named_parameters=...), which cannot collide with an option name.
- Returns:
An instance of a
AnalyticsResultwhich provides access to iterate over the analytics query results and access metadata and metrics about the analytics query.- Return type:
Deferred[
AnalyticsResult]
- collection(name: str) Collection
Creates a
Collectioninstance of the specified collection.- Parameters:
name (str) – Name of the collection to reference.
- Returns:
A
Collectioninstance of the specified collection.- Return type:
- query(statement: str, *options: QueryOptions | str | int | float | bool | None | Mapping[str, Any] | Sequence[Any], **kwargs: Any) Deferred[QueryResult]
Executes a N1QL query against the scope.
Note
The query is sent when this is called, and the Deferred fires once the core has buffered the response, so iterating the
QueryResultdoes not block the reactor.Note
Scope-level queries are only supported on Couchbase Server versions that support scopes and collections.
See also
QueryIndexManager: For how to manage query indexes.query(): For how to execute cluster-level queries.
- Parameters:
statement (str) – The N1QL statement to execute.
options (
QueryOptions) – Optional parameters for the query operation.**kwargs – keyword arguments that can be used in place or to override provided
QueryOptions. A keyword that is not one of its options is sent as a named parameter; preferQueryOptions(named_parameters=...), which cannot collide with an option name.
- Returns:
An instance of a
QueryResultwhich provides access to iterate over the query results and access metadata and metrics about the query.- Return type:
Deferred[
QueryResult]
- search(index: str, request: SearchRequest | SearchQuery, options: SearchOptions | None = None, **kwargs: Unpack[SearchOptionsKwargs]) Deferred[SearchResult]
Executes an search against the scope.
Note
The search is sent when this is called, and the Deferred fires once the core has buffered the response, so iterating the
SearchResultdoes not block the reactor.See also
ScopeSearchIndexManager: for how to manage search indexes.search(): for how to execute cluster-level search
- Parameters:
index (str) – Name of the search index to use.
request (
SearchRequest|SearchQuery) –Type of search request to perform.
Deprecated since version 4.7.0: Passing a
SearchQueryis deprecated; wrap it withcreate()instead.options (
SearchOptions) – Optional parameters for the search query operation.**kwargs – keyword arguments that can be used in place or to override provided
SearchOptions
- Returns:
An instance of a
SearchResultwhich provides access to iterate over the search query results and access metadata and metrics about the search query.- Return type:
Deferred[
SearchResult]
- search_indexes() ScopeSearchIndexManager
Get a manager for the search indexes of this scope.
- Returns:
A
ScopeSearchIndexManagerinstance.- Return type:
- search_query(index: str, query: SearchQuery, options: SearchOptions | None = None, **kwargs: Unpack[SearchOptionsKwargs]) Deferred[SearchResult]
Executes an search query against the scope.
Deprecated since version 4.1.11: Use
search()instead.Note
The search query is sent when this is called, and the Deferred fires once the core has buffered the response, so iterating the
SearchResultdoes not block the reactor.- Parameters:
index (str) – Name of the search query to use.
query (
SearchQuery) – Type of search query to perform.options (
SearchOptions) – Optional parameters for the search query operation.**kwargs – keyword arguments that can be used in place or to override provided
SearchOptions
- Returns:
An instance of a
SearchResultwhich provides access to iterate over the search query results and access metadata and metrics about the search query.- Return type:
Deferred[
SearchResult]- Raises:
InvalidArgumentException – If a
SearchRequestis provided. Usesearch()for a search request.