API Docs for: 2.2.2
Show:

SecondaryIndexQuery.Builder Class

A builder for constructing SecondaryIndexquery instances.

Rather than having to manually construct the options and instantiating a SecondaryIndexQuery directly, this builder may be used.

var query = new SecondaryIndexQuery.Builder()
             .withBucket('myBucket')
             .withIndexName('email_bin')
             .withIndexKey('roach@basho.com')
             .withCallback(myCallback)
             .build();

Constructor

SecondaryIndexQuery.Builder

()

Methods

build

() SecondaryIndexQuery

Construct a SecondaryIndexQuery instance

withBucket

(
  • bucket
)
chainable

Set the bucket.

Parameters:

  • bucket String

    the bucket in Riak

(
  • indexName
)
chainable

Set the index name

Parameters:

  • indexName String

    the index to query

withBucketType

(
  • bucketType
)
chainable

Set the bucket type. If not supplied, 'default' is used.

Parameters:

  • bucketType String

    the bucket type in riak

withCallback

(
  • callback
)
chainable

Set the callback to be executed when the operation completes.

Parameters:

  • callback Function

    the callback to be executed by the command.

    • err String

      An error message. Will ne null if no error.

    • response Object

      The response from Riak.

      • values Object
        Object keys returned by the query, and optionally the index keys.
      • done Boolean
        True if you have received all the results.
      • continuation Buffer
        The continuation if a continuation was returned.

withContinuation

(
  • continuation
)
chainable

Set the continuation for this query. If using pagination via maxResults, this will have been returned by a previous query.

Parameters:

  • continuation Buffer

    the continuation from a previous query

withIndexKey

(
  • indexKey
)
chainable

Set a single secondary index key to use for query. Note that you can only set a single key, or a range.

Parameters:

  • indexKey String | Number

    the secondary index key.

withMaxResults

(
  • maxResults
)
chainable

Set the maximum number of results returned by the query.

When asking for large result sets, it is often desirable to ask the servers to return chunks of results instead of a firehose. You can do so using this method, where maxResults is the number of results you'd like to receive.

Assuming more keys are available, a continuation value will be included in the results to allow the client to request the next page.

Parameters:

  • maxResults Number

    the max number of results to return.

withPaginationSort

(
  • paginationSort
)
chainable

Set whether to sort the results of a non-paginated 2i query. If you are not using pagination (setting withMaxResults()) the default behavior in Riak is to not sort the result set. Setting this to true will sort the results before returning them. __Note that this is not recommended for queries that could return a large result set; the overhead in Riak is substantial. __

Parameters:

  • paginationSort Boolean

    true to sort the results of a non-paginated query

withRange

(
  • start
  • end
)
chainable

Set a range for the query

Parameters:

  • start String | Number

    the start of the range

  • end String | Number

    the end of the range

withReturnKeyAndIndex

(
  • returnKeyAndIndex
)
chainable

Set whether to return the index keys with the Riak object keys. Setting this to true will return both the index key and the Riak object's key. The default is false (only to return the Riak object keys).

Parameters:

  • returnKeyAndIndex Boolean

    whether to return the index keys as well

withStreaming

(
  • [stream=true]
)
chainable

Stream the results. Setting this to true will cause you callback to be called as the results are returned from Riak. Set to false the result set will be buffered and delevered via a single call to your callback. Note that on large result sets this is very memory intensive.

Parameters:

  • [stream=true] Boolean optional

    Set whether or not to stream the results

withTimeout

(
  • timeout
)
chainable

Set a timeout for this operation.

Parameters:

  • timeout Number

    a timeout in milliseconds.