Package com.couchbase.client.java.query
Class QueryOptions
- java.lang.Object
-
- com.couchbase.client.java.CommonOptions<QueryOptions>
-
- com.couchbase.client.java.query.QueryOptions
-
@Volatile public class QueryOptions extends CommonOptions<QueryOptions>
N1QL query request options.- Since:
- 3.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
QueryOptions.Built
-
Nested classes/interfaces inherited from class com.couchbase.client.java.CommonOptions
CommonOptions.BuiltCommonOptions
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryOptions
adhoc(boolean adhoc)
If set to false, enables transparent prepared statement support.QueryOptions.Built
build()
QueryOptions
clientContextId(String clientContextId)
Adds a client context ID to the request, that will be sent back in the response, allowing clients to meaningfully trace requests/responses when many are exchanged.QueryOptions
consistentWith(MutationToken... tokens)
Sets theMutationToken
s this query should be consistent with.QueryOptions
consistentWith(List<MutationToken> tokens)
Sets theMutationToken
s this query should be consistent with.QueryOptions
credentials(String user, String password)
Additional credentials for the queryQueryOptions
maxParallelism(int maxParallelism)
Allows to override the default maximum parallelism for the query execution on the server side.QueryOptions
metricsDisabled(boolean metricsDisabled)
If set to true (false being the default), the metrics object will not be returned from N1QL and as a result be more efficient.QueryOptions
parameters(JsonArray positional)
Positional parameters if the query is parameterized with position numbersQueryOptions
parameters(JsonObject named)
Named parameters if the query is parameterized with custom namesQueryOptions
pipelineBatch(int pipelineBatch)
Advanced: Controls the number of items execution operators can batch for Fetch from the KV.QueryOptions
pipelineCap(int pipelineCap)
Advanced: Maximum number of items each execution operator can buffer between various operators.QueryOptions
prepared(boolean prepared)
Set to true if the query is already prepared/to be preparedQueryOptions
profile(QueryProfile queryProfile)
Set the profiling information level for query executionstatic QueryOptions
queryOptions()
QueryOptions
rawParams(String param, Object value)
Raw parameters for the queryQueryOptions
readonlyEnabled(boolean readonlyEnabled)
If set to true, it will signal the query engine on the server that only non-data modifying requests are allowed.QueryOptions
scanCap(int scanCap)
Advanced: Maximum buffered channel size between the indexer client and the query service for index scans.QueryOptions
scanConsistency(ScanConsistency scanConsistency)
Scan consistency for the queryQueryOptions
scanWait(Duration wait)
If thescan consistency
has been chosen, does nothing.-
Methods inherited from class com.couchbase.client.java.CommonOptions
clientContext, retryStrategy, self, timeout
-
-
-
-
Method Detail
-
queryOptions
public static QueryOptions queryOptions()
-
rawParams
public QueryOptions rawParams(String param, Object value)
Raw parameters for the query- Parameters:
param
- the parameter namevalue
- the parameter value- Returns:
QueryOptions
for further chaining
-
credentials
public QueryOptions credentials(String user, String password)
Additional credentials for the query- Parameters:
user
- the user namepassword
- the user password- Returns:
QueryOptions
for further chaining
-
adhoc
public QueryOptions adhoc(boolean adhoc)
If set to false, enables transparent prepared statement support.- Parameters:
adhoc
- if this is an ad-hoc query.- Returns:
QueryOptions
for further chaining.
-
scanConsistency
public QueryOptions scanConsistency(ScanConsistency scanConsistency)
Scan consistency for the query- Parameters:
scanConsistency
- the index scan consistency to be used- Returns:
QueryOptions
for further chaining
-
profile
public QueryOptions profile(QueryProfile queryProfile)
Set the profiling information level for query execution- Parameters:
queryProfile
- the query profile level to be used- Returns:
QueryOptions
for further chaining
-
clientContextId
public QueryOptions clientContextId(String clientContextId)
Adds a client context ID to the request, that will be sent back in the response, allowing clients to meaningfully trace requests/responses when many are exchanged.- Parameters:
clientContextId
- the client context ID (null to send none)- Returns:
- this
QueryOptions
for chaining.
-
metricsDisabled
public QueryOptions metricsDisabled(boolean metricsDisabled)
If set to true (false being the default), the metrics object will not be returned from N1QL and as a result be more efficient. Note that if metrics are disabled you are losing information to diagnose problems - so use with care!- Parameters:
metricsDisabled
- true if disabled, false otherwise (false = default).- Returns:
- this
QueryOptions
for chaining.
-
scanWait
public QueryOptions scanWait(Duration wait)
If thescan consistency
has been chosen, does nothing. Otherwise, sets the maximum time the client is willing to wait for an index to catch up to the vector timestamp in the request.- Parameters:
wait
- the duration.- Returns:
- this
QueryOptions
for chaining.
-
maxParallelism
public QueryOptions maxParallelism(int maxParallelism)
Allows to override the default maximum parallelism for the query execution on the server side.- Parameters:
maxParallelism
- the maximum parallelism for this query, 0 or negative values disable it.- Returns:
- this
QueryOptions
for chaining.
-
readonlyEnabled
public QueryOptions readonlyEnabled(boolean readonlyEnabled)
If set to true, it will signal the query engine on the server that only non-data modifying requests are allowed. Note that this rule is enforced on the server and not the SDK side. Controls whether a query can change a resulting record set. If readonly is true, then the following statements are not allowed: - CREATE INDEX - DROP INDEX - INSERT - MERGE - UPDATE - UPSERT - DELETE- Parameters:
readonlyEnabled
- true if readonly should be forced, false is the default and will use the server side default.- Returns:
- this
QueryOptions
for chaining.
-
scanCap
public QueryOptions scanCap(int scanCap)
Advanced: 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.- Parameters:
scanCap
- the scan_cap param, use 0 or negative number to disable.- Returns:
- this
QueryOptions
for chaining.
-
pipelineBatch
public QueryOptions pipelineBatch(int pipelineBatch)
Advanced: Controls the number of items execution operators can batch for Fetch from the KV.- Parameters:
pipelineBatch
- the pipeline_batch param.- Returns:
- this
QueryOptions
for chaining.
-
pipelineCap
public QueryOptions pipelineCap(int pipelineCap)
Advanced: Maximum number of items each execution operator can buffer between various operators.- Parameters:
pipelineCap
- the pipeline_cap param.- Returns:
- this
QueryOptions
for chaining.
-
parameters
public QueryOptions parameters(JsonObject named)
Named parameters if the query is parameterized with custom names- Parameters:
named
-JsonObject
with name as key- Returns:
- this
QueryOptions
for chaining.
-
parameters
public QueryOptions parameters(JsonArray positional)
Positional parameters if the query is parameterized with position numbers- Parameters:
positional
-JsonArray
in the same order as positions- Returns:
- this
QueryOptions
for chaining.
-
prepared
public QueryOptions prepared(boolean prepared)
Set to true if the query is already prepared/to be prepared- Parameters:
prepared
- true if prepared, else false- Returns:
- this
QueryOptions
for chaining.
-
consistentWith
public QueryOptions consistentWith(MutationToken... tokens)
Sets theMutationToken
s this query should be consistent with. These tokens are returned from mutations.- Parameters:
tokens
- the mutation tokens- Returns:
- this
QueryOptions
for chaining.
-
consistentWith
public QueryOptions consistentWith(List<MutationToken> tokens)
Sets theMutationToken
s this query should be consistent with. These tokens are returned from mutations.- Parameters:
tokens
- the mutation tokens- Returns:
- this
QueryOptions
for chaining.
-
build
@Internal public QueryOptions.Built build()
-
-