Class AnalyticsOptions

java.lang.Object
com.couchbase.client.java.CommonOptions<AnalyticsOptions>
com.couchbase.client.java.analytics.AnalyticsOptions

public class AnalyticsOptions extends CommonOptions<AnalyticsOptions>
Allows customizing various analytics query options.

This object is NOT thread safe and must be constructed on a single thread and then passed to the Cluster.analyticsQuery(String, AnalyticsOptions) method.

Since:
3.0.0
  • Method Details

    • analyticsOptions

      public static AnalyticsOptions analyticsOptions()
      Creates new AnalyticsOptions with all default params set.
      Returns:
      constructed AnalyticsOptions with its default values.
    • priority

      public AnalyticsOptions priority(boolean priority)
      Allows assigning a different server-side priority to the current query.
      Parameters:
      priority - if this request should have higher priority than other requests on the server.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • clientContextId

      public AnalyticsOptions clientContextId(String clientContextId)
      Supports providing a custom client context ID for this query.

      If no client context ID is provided by the user, a UUID is generated and sent automatically so by default it is always possible to identify a query when debugging. If you do not want to send one, pass either null or an empty string to this method.

      Parameters:
      clientContextId - the client context ID - if null or empty it will not be sent.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • readonly

      @SinceCouchbase("6.5") public AnalyticsOptions readonly(boolean readonly)
      Allows explicitly marking a query as being readonly and not mutating and documents on the server side.

      In addition to providing some security in that you are not accidentally modifying data, setting this flag to true also helps the client to more proactively retry and re-dispatch a query since then it can be sure it is idempotent. As a result, if your query is readonly then it is a good idea to set this flag.

      Note that this property is only supported when using Couchbase Server 6.5 or later.

      Parameters:
      readonly - true if readonly should be set, false is the default and will use the server side default.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • serializer

      public AnalyticsOptions serializer(JsonSerializer serializer)
      Provides a custom JsonSerializer to be used for decoding the rows as they return from the server.

      If no serializer is provided, the default one from the ClusterEnvironment will be used (which is sufficient for most tasks at hand).

      Parameters:
      serializer - a custom serializer for this request.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • scanConsistency

      public AnalyticsOptions scanConsistency(AnalyticsScanConsistency scanConsistency)
      Customizes the consistency guarantees for this query.

      Tuning the scan consistency allows to trade data "freshness" for latency and vice versa. By default AnalyticsScanConsistency.NOT_BOUNDED is used, which means that the server returns the data it has in the index right away. This is fast, but might not include the most recent mutations. If you want to include all the mutations up to the point of the query, use AnalyticsScanConsistency.REQUEST_PLUS.

      Parameters:
      scanConsistency - the index scan consistency to be used for this query.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • scanWait

      @Uncommitted public AnalyticsOptions scanWait(Duration wait)
      Allows customizing how long the query engine is willing to wait until the index catches up to whatever scan consistency is asked for in this query.

      Note that if AnalyticsScanConsistency.NOT_BOUNDED is used (which is the default), this method doesn't do anything at all. If no value is provided to this method, the server default is used.

      Parameters:
      wait - the maximum duration the analytics engine should wait before failing.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • parameters

      public AnalyticsOptions parameters(JsonObject named)
      Sets named parameters for this query.

      Note that named and positional parameters cannot be used at the same time. If one is set, the other one is "nulled" out and not being sent to the server.

      Parameters:
      named - JsonObject the named parameters.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • parameters

      public AnalyticsOptions parameters(JsonArray positional)
      Sets positional parameters for this query.

      Note that named and positional parameters cannot be used at the same time. If one is set, the other one is "nulled" out and not being sent to the server.

      Parameters:
      positional - JsonArray the positional parameters.
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • raw

      public AnalyticsOptions raw(String key, Object value)
      Allows providing custom JSON key/value pairs for advanced usage.

      If available, it is recommended to use the methods on this object to customize the query. This method should only be used if no such setter can be found (i.e. if an undocumented property should be set or you are using an older client and a new server-configuration property has been added to the cluster).

      Note that the value will be passed through a JSON encoder, so do not provide already encoded JSON as the value. If you want to pass objects or arrays, you can use JsonObject and JsonArray respectively.

      Parameters:
      key - the parameter name (key of the JSON property) or empty.
      value - the parameter value (value of the JSON property).
      Returns:
      the same AnalyticsOptions for chaining purposes.
    • build