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:
-
bucket
Stringthe bucket in Riak
-
indexName
Set the index name
Parameters:
-
indexName
Stringthe index to query
withBucketType
-
bucketType
Set the bucket type. If not supplied, 'default' is used.
Parameters:
-
bucketType
Stringthe bucket type in riak
withCallback
-
callback
Set the callback to be executed when the operation completes.
Parameters:
-
callback
Functionthe callback to be executed by the command.
-
err
StringAn error message. Will ne null if no error.
-
response
ObjectThe response from Riak.
-
values
ObjectObject keys returned by the query, and optionally the index keys. -
done
BooleanTrue if you have received all the results. -
continuation
BufferThe 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:
-
continuation
Bufferthe 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:
-
indexKey
String | 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:
-
maxResults
Numberthe 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:
-
paginationSort
Booleantrue to sort the results of a non-paginated query
withRange
-
start
-
end
Set a range for the query
Parameters:
-
start
String | Numberthe start of the range
-
end
String | 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:
-
returnKeyAndIndex
Booleanwhether 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:
-
timeout
Numbera timeout in milliseconds.