query

suspend fun query(statement: String, parameters: QueryParameters = QueryParameters.None, scope: Scope? = null, serializer: JsonSerializer? = null, consistency: QueryScanConsistency = QueryScanConsistency.requestPlus(), readonly: Boolean = false, adhoc: Boolean = true, flexIndex: Boolean = false, profile: QueryProfile = QueryProfile.OFF, scanCap: Int? = null, pipelineBatch: Int? = null, pipelineCap: Int? = null, clientContextId: String? = UUID.randomUUID().toString(), raw: Map<String, Any?> = emptyMap()): QueryResult

Executes a SQL++ query, buffers all result rows in memory, and returns them as a QueryResult.

Parameters

statement

the SQL++ statement to execute.

parameters

parameters to the SQL++ statement.

scope

the query context, or null to execute a cluster-level query.

serializer

the serializer to use for converting parameters to JSON, and the default serializer for parsing QueryRow content. Defaults to the serializer configured on the cluster environment.

consistency

the scan consistency level for this query. Only QueryScanConsistency.requestPlus and QueryScanConsistency.notBounded are supported in transactions. Note that the default scan consistency for transactional queries is QueryScanConsistency.requestPlus; this differs from non-transaction queries, which default to QueryScanConsistency.notBounded.

readonly

pass true if the SQL++ statement does not modify documents. This enables certain optimizations, and ensures a query fails instead of accidentally modifying data.

adhoc

pass false if this is a commonly used query that should be turned into a prepared statement for faster execution.

flexIndex

pass true to use a full-text index instead of a query index.

profile

specifies how much profiling information to include in the response (access via QueryMetadata.profile). Profiling is relatively expensive, and can impact the performance of the server query engine. Not recommended for use in production, unless you're diagnosing a specific issue. Note this is an Enterprise Edition feature. On Community Edition the parameter will be accepted, but no profiling information returned.

scanCap

Maximum buffered channel size between the indexer client and the query service for index scans. This parameter controls when to use scan backfill. Use 0 or a negative number to disable. Smaller values reduce GC, while larger values reduce indexer backfill.

pipelineBatch

Controls the number of items execution operators can batch for Fetch from the KV.

pipelineCap

Maximum number of items each execution operator can buffer between various operators.

clientContextId

an arbitrary string that identifies this query for diagnostic purposes.

raw

an "escape hatch" for passing arbitrary query options that aren't otherwise exposed by this method.