API Docs for: 2.2.2
Show:

SecondaryIndexQuery Class

Command used to perform a secondary index query.

As a convenience, a builder class is provided:

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

See SecondaryIndexQuery.Builder

Constructor

SecondaryIndexQuery

(
  • options
  • callback
)

Parameters:

  • options Object

    The options for this command.

    • [bucketType=default] String optional

      The bucket type in riak. If not supplied 'default' is used.

    • bucket String

      The bucket in riak.

    • indexName String

      The secondary index name to query

    • [indexKey] String | Number optional

      A single index key to query

    • [rangeStart] String | Number optional

      Starting key for a range query

    • [rangeEnd] String | Number optional

      Ending key for a range query

    • [returnKeyAndIndex=false] Boolean optional

      Return the index keys along with the object keys

    • [maxResults] Number optional

      Limit the results returned and paginate if necessary

    • [continuation] Buffer optional

      A continuation returned from a previous query that set maxResults. Used for pagination.

    • [stream=true] Boolean optional

      Whether to stream or accumulate the result before calling callback.

    • [timeout] Number optional

      Set a timeout for this operation.

    • [paginationSort=false] Boolean optional

      True to sort a non-paginated query.

  • 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.
    • data Object

      additional error data. Will be null if no error.

Methods

constructPbRequest

() Object protected
Construct and return the Riak protocol buffer message for this command. Subclasses must override this method.

Returns:

Object: a protocol buffer message builder

getCallback

() Function private
Fires the user's callback with the arguments passed in.

Returns:

Function: the user supplied callback

getExpectedResponseCode

() Number private
Returns the expected response code for this command.

Returns:

Number: the expected response code for this command.

getPbReqBuilder

() Object private
Returns and instance of the protocol buffer message builder for this command. This is determined via the pbRequestName passed to the constructor.

Returns:

Object: the builder for the protocol buffer message to be sent for this command

getRiakMessage

() Object private
Returns the encoded protobuf and message header.

Returns:

Object: object containing the header and encoded protobuf

onError

(
  • msg
  • data
)
protected
Called by RiakNode if an error occurs executing the command and all retries are exhausted.

Parameters:

  • msg String
    an error message
  • data Object
    additional error data

onRiakError

(
  • rpbErrorResp
)
protected
Called by RiakNode when a RpbErrorResp is received and all retries are exhausted. Commands may override this method.

Parameters:

  • rpbErrorResp Object
    the RpbErrorResp protocol buffer

onSuccess

(
  • pbResponseMessage
)
Boolean protected
Called by RiakNode when a response is received. Subclasses must override this method.

Parameters:

  • pbResponseMessage Object
    the protocol buffer received from riak

Returns:

Boolean: true if not streaming or the last response has been received, false otherwise.