Class CosmosQueryRequestOptions
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the consistency level required for the request.Gets the custom item serializer defined for this instance of request optionsGets the Dedicated Gateway Request OptionsGets the diagnostic thresholds used as an override for a specific operation.Gets the list of regions to exclude for the request/retries.Gets theFeedRange
Gets the custom ids.int
Gets the maximum number of items that can be buffered client side during parallel query execution.int
Gets the number of concurrent operations run client side during parallel query execution.Gets the partition key used to identify the current request's target partition.int
Gets the ResponseContinuationTokenLimitInKb request option for item query requests in the Azure Cosmos DB service.Gets the session token for use with session consistency.Gets the thresholdForDiagnosticsOnTracer, if latency on query operation is greater than this diagnostics will be send to open telemetry exporter as events in tracer span of end to end CRUD api.Get throughput control group name.boolean
Gets indexMetricsEnabled, which is used to obtain the index metrics to understand how the query engine used existing indexes and could use potential new indexes.boolean
Gets the option to enable populate query metrics.Gets the option to allow scan on the queries which couldn't be served as indexing was opted out on the requested paths.setConsistencyLevel
(ConsistencyLevel consistencyLevel) Sets the consistency level required for the request.setCosmosEndToEndOperationLatencyPolicyConfig
(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig) Sets theCosmosEndToEndOperationLatencyPolicyConfig
to be used for the request.setCustomItemSerializer
(CosmosItemSerializer customItemSerializer) Allows specifying a custom item serializer to be used for this operation.setDedicatedGatewayRequestOptions
(DedicatedGatewayRequestOptions dedicatedGatewayRequestOptions) Sets the Dedicated Gateway Request OptionssetDiagnosticsThresholds
(CosmosDiagnosticsThresholds operationSpecificThresholds) Allows overriding the diagnostic thresholds for a specific operation.setExcludedRegions
(List<String> excludeRegions) List of regions to be excluded for the request/retries.setFeedRange
(FeedRange feedRange) Sets theFeedRange
that we want to querysetIndexMetricsEnabled
(boolean indexMetricsEnabled) Sets indexMetricsEnabled, which is used to obtain the index metrics to understand how the query engine used existing indexes and could use potential new indexes.setKeywordIdentifiers
(Set<String> keywordIdentifiers) Sets the custom ids.setMaxBufferedItemCount
(int maxBufferedItemCount) Sets the maximum number of items that can be buffered client side during parallel query execution.setMaxDegreeOfParallelism
(int maxDegreeOfParallelism) Sets the number of concurrent operations run client side during parallel query execution.setPartitionKey
(PartitionKey partitionkey) Sets the partition key used to identify the current request's target partition.setQueryMetricsEnabled
(boolean queryMetricsEnabled) Sets the option to enable/disable getting metrics relating to query execution on item query requests.setQueryName
(String queryName) Sets the logical query name - this identifier is only used for metrics and logs to distinguish different queries in telemetry.setResponseContinuationTokenLimitInKb
(int limitInKb) Sets the ResponseContinuationTokenLimitInKb request option for item query requests in the Azure Cosmos DB service.setScanInQueryEnabled
(Boolean scanInQueryEnabled) Sets the option to allow scan on the queries which couldn't be served as indexing was opted out on the requested paths.setSessionToken
(String sessionToken) Sets the session token for use with session consistency.setThresholdForDiagnosticsOnTracer
(Duration thresholdForDiagnosticsOnTracer) Sets the thresholdForDiagnosticsOnTracer, if latency on query operation is greater than this diagnostics will be send to open telemetry exporter as events in tracer span of end to end CRUD api.setThroughputControlGroupName
(String throughputControlGroupName) Set the throughput control group name.
-
Constructor Details
-
CosmosQueryRequestOptions
public CosmosQueryRequestOptions()Instantiates a new query request options.
-
-
Method Details
-
getConsistencyLevel
Gets the consistency level required for the request.- Returns:
- the consistency level.
-
setConsistencyLevel
Sets the consistency level required for the request. The effective consistency level can only be reduce for read/query requests. So when the Account's default consistency level is for example Session you can specify on a request-by-request level for individual requests that Eventual consistency is sufficient - which could reduce the latency and RU charges for this request but will not guarantee session consistency (read-your-own-write) anymore- Parameters:
consistencyLevel
- the consistency level.- Returns:
- the CosmosItemRequestOptions.
-
getSessionToken
Gets the session token for use with session consistency.- Returns:
- the session token.
-
setSessionToken
Sets the session token for use with session consistency.- Parameters:
sessionToken
- the session token.- Returns:
- the CosmosQueryRequestOptions.
-
isScanInQueryEnabled
Gets the option to allow scan on the queries which couldn't be served as indexing was opted out on the requested paths.- Returns:
- the option of enable scan in query.
-
setScanInQueryEnabled
Sets the option to allow scan on the queries which couldn't be served as indexing was opted out on the requested paths.- Parameters:
scanInQueryEnabled
- the option of enable scan in query.- Returns:
- the CosmosQueryRequestOptions.
-
getMaxDegreeOfParallelism
public int getMaxDegreeOfParallelism()Gets the number of concurrent operations run client side during parallel query execution.- Returns:
- number of concurrent operations run client side during parallel query execution.
-
setMaxDegreeOfParallelism
Sets the number of concurrent operations run client side during parallel query execution.- Parameters:
maxDegreeOfParallelism
- number of concurrent operations.- Returns:
- the CosmosQueryRequestOptions.
-
getMaxBufferedItemCount
public int getMaxBufferedItemCount()Gets the maximum number of items that can be buffered client side during parallel query execution.- Returns:
- maximum number of items that can be buffered client side during parallel query execution.
-
setMaxBufferedItemCount
Sets the maximum number of items that can be buffered client side during parallel query execution.- Parameters:
maxBufferedItemCount
- maximum number of items.- Returns:
- the CosmosQueryRequestOptions.
-
setResponseContinuationTokenLimitInKb
Sets the ResponseContinuationTokenLimitInKb request option for item query requests in the Azure Cosmos DB service.ResponseContinuationTokenLimitInKb is used to limit the length of continuation token in the query response. Valid values are >= 1.
The continuation token contains both required and optional fields. The required fields are necessary for resuming the execution from where it was stooped. The optional fields may contain serialized index lookup work that was done but not yet utilized. This avoids redoing the work again in subsequent continuations and hence improve the query performance. Setting the maximum continuation size to 1KB, the Azure Cosmos DB service will only serialize required fields. Starting from 2KB, the Azure Cosmos DB service would serialize as much as it could fit till it reaches the maximum specified size.
- Parameters:
limitInKb
- continuation token size limit.- Returns:
- the CosmosQueryRequestOptions.
-
getResponseContinuationTokenLimitInKb
public int getResponseContinuationTokenLimitInKb()Gets the ResponseContinuationTokenLimitInKb request option for item query requests in the Azure Cosmos DB service. If not already set returns 0.ResponseContinuationTokenLimitInKb is used to limit the length of continuation token in the query response. Valid values are >= 1.
- Returns:
- return set ResponseContinuationTokenLimitInKb, or 0 if not set
-
setCosmosEndToEndOperationLatencyPolicyConfig
public CosmosQueryRequestOptions setCosmosEndToEndOperationLatencyPolicyConfig(CosmosEndToEndOperationLatencyPolicyConfig cosmosEndToEndOperationLatencyPolicyConfig) Sets theCosmosEndToEndOperationLatencyPolicyConfig
to be used for the request. If the config is already set * on the client, then this will override the client level config for this request- Parameters:
cosmosEndToEndOperationLatencyPolicyConfig
- theCosmosEndToEndOperationLatencyPolicyConfig
- Returns:
- the CosmosQueryRequestOptions
-
setExcludedRegions
List of regions to be excluded for the request/retries. Example "East US" or "East US, West US" These regions will be excluded from the preferred regions list- Parameters:
excludeRegions
- the regions to exclude- Returns:
- the
CosmosQueryRequestOptions
-
getExcludedRegions
Gets the list of regions to exclude for the request/retries. These regions are excluded from the preferred region list.- Returns:
- a list of excluded regions
-
getPartitionKey
Gets the partition key used to identify the current request's target partition.- Returns:
- the partition key.
-
setPartitionKey
Sets the partition key used to identify the current request's target partition.- Parameters:
partitionkey
- the partition key value.- Returns:
- the CosmosQueryRequestOptions.
-
isQueryMetricsEnabled
public boolean isQueryMetricsEnabled()Gets the option to enable populate query metrics. By default query metrics are enabled.- Returns:
- whether to enable populate query metrics (default: true)
-
setQueryMetricsEnabled
Sets the option to enable/disable getting metrics relating to query execution on item query requests. By default query metrics are enabled.- Parameters:
queryMetricsEnabled
- whether to enable or disable query metrics- Returns:
- the CosmosQueryRequestOptions.
-
getFeedRange
Gets theFeedRange
- Returns:
- the
FeedRange
-
setFeedRange
Sets theFeedRange
that we want to query- Parameters:
feedRange
- theFeedRange
- Returns:
- the CosmosQueryRequestOptions.
-
getThroughputControlGroupName
Get throughput control group name.- Returns:
- The throughput control group name.
-
setThroughputControlGroupName
Set the throughput control group name.- Parameters:
throughputControlGroupName
- The throughput control group name.- Returns:
- A
CosmosQueryRequestOptions
.
-
getDedicatedGatewayRequestOptions
Gets the Dedicated Gateway Request Options- Returns:
- the Dedicated Gateway Request Options
-
setDedicatedGatewayRequestOptions
public CosmosQueryRequestOptions setDedicatedGatewayRequestOptions(DedicatedGatewayRequestOptions dedicatedGatewayRequestOptions) Sets the Dedicated Gateway Request Options- Parameters:
dedicatedGatewayRequestOptions
- Dedicated Gateway Request Options- Returns:
- the CosmosQueryRequestOptions
-
getThresholdForDiagnosticsOnTracer
Gets the thresholdForDiagnosticsOnTracer, if latency on query operation is greater than this diagnostics will be send to open telemetry exporter as events in tracer span of end to end CRUD api. Default is 500 ms.- Returns:
- thresholdForDiagnosticsOnTracer the latency threshold for diagnostics on tracer.
-
setThresholdForDiagnosticsOnTracer
public CosmosQueryRequestOptions setThresholdForDiagnosticsOnTracer(Duration thresholdForDiagnosticsOnTracer) Sets the thresholdForDiagnosticsOnTracer, if latency on query operation is greater than this diagnostics will be send to open telemetry exporter as events in tracer span of end to end CRUD api. Default is 500 ms- Parameters:
thresholdForDiagnosticsOnTracer
- the latency threshold for diagnostics on tracer.- Returns:
- the CosmosQueryRequestOptions
-
setDiagnosticsThresholds
public CosmosQueryRequestOptions setDiagnosticsThresholds(CosmosDiagnosticsThresholds operationSpecificThresholds) Allows overriding the diagnostic thresholds for a specific operation.- Parameters:
operationSpecificThresholds
- the diagnostic threshold override for this operation- Returns:
- the CosmosQueryRequestOptions.
-
getDiagnosticsThresholds
Gets the diagnostic thresholds used as an override for a specific operation. If no operation specific diagnostic threshold has been specified, this method will return null, although at runtime the default thresholds specified at the client-level will be used.- Returns:
- the diagnostic thresholds used as an override for a specific operation.
-
isIndexMetricsEnabled
public boolean isIndexMetricsEnabled()Gets indexMetricsEnabled, which is used to obtain the index metrics to understand how the query engine used existing indexes and could use potential new indexes. The results will be displayed in QueryMetrics. Please note that this options will incurs overhead, so it should be enabled when debuging slow queries.- Returns:
- indexMetricsEnabled (default: false)
-
setIndexMetricsEnabled
Sets indexMetricsEnabled, which is used to obtain the index metrics to understand how the query engine used existing indexes and could use potential new indexes. The results will be displayed in QueryMetrics. Please note that this options will incurs overhead, so it should be enabled when debugging slow queries. By default the indexMetrics are disabled.- Parameters:
indexMetricsEnabled
- a boolean used to obtain the index metrics- Returns:
- indexMetricsEnabled
-
setQueryName
Sets the logical query name - this identifier is only used for metrics and logs to distinguish different queries in telemetry. Cardinality of unique values for queryName should be reasonably low - like significantly smaller than 100.- Parameters:
queryName
- a logical query name to distinguish this query pattern from others- Returns:
- the logical query name
-
getCustomItemSerializer
Gets the custom item serializer defined for this instance of request options- Returns:
- the custom item serializer
-
setCustomItemSerializer
Allows specifying a custom item serializer to be used for this operation. If the serializer on the request options is null, the serializer on CosmosClientBuilder is used. If both serializers are null (the default), an internal Jackson ObjectMapper is ued for serialization/deserialization.- Parameters:
customItemSerializer
- the custom item serializer for this operation- Returns:
- the CosmosItemRequestOptions.
-
setKeywordIdentifiers
Sets the custom ids.- Parameters:
keywordIdentifiers
- the custom ids.- Returns:
- the current request options.
-
getKeywordIdentifiers
Gets the custom ids.- Returns:
- the custom ids.
-