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
()
Item Index
Methods
withBucket
-
bucket
Set the bucket.
Parameters:
-
bucketStringthe bucket in Riak
-
indexName
Set the index name
Parameters:
-
indexNameStringthe index to query
withBucketType
-
bucketType
Set the bucket type. If not supplied, 'default' is used.
Parameters:
-
bucketTypeStringthe bucket type in riak
withCallback
-
callback
Set the callback to be executed when the operation completes.
Parameters:
-
callbackFunctionthe callback to be executed by the command.
-
errStringAn error message. Will ne null if no error.
-
responseObjectThe response from Riak.
-
valuesObjectObject keys returned by the query, and optionally the index keys. -
doneBooleanTrue if you have received all the results. -
continuationBufferThe continuation if a continuation was returned.
-
-
withContinuation
-
continuation
Set the continuation for this query. If using pagination via maxResults, this will have been returned by a previous query.
Parameters:
-
continuationBufferthe continuation from a previous query
withIndexKey
-
indexKey
Set a single secondary index key to use for query. Note that you can only set a single key, or a range.
Parameters:
-
indexKeyString | Numberthe secondary index key.
withMaxResults
-
maxResults
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:
-
maxResultsNumberthe max number of results to return.
withPaginationSort
-
paginationSort
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:
-
paginationSortBooleantrue to sort the results of a non-paginated query
withRange
-
start -
end
Set a range for the query
Parameters:
-
startString | Numberthe start of the range
-
endString | Numberthe end of the range
withReturnKeyAndIndex
-
returnKeyAndIndex
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:
-
returnKeyAndIndexBooleanwhether to return the index keys as well
withStreaming
-
[stream=true]
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 optionalSet whether or not to stream the results
withTimeout
-
timeout
Set a timeout for this operation.
Parameters:
-
timeoutNumbera timeout in milliseconds.
