code: def index(self, bucket, index, startkey, endkey=None, bucket_type=None):
          
          self._input_mode = 'query'
  
          if endkey is None:
              self._inputs = {'bucket': bucket,
                              'index': index,
                              'key': startkey}
          else:
              self._inputs = {'bucket': bucket,
                              'index': index,
                              'start': startkey,
                              'end': endkey}
          if bucket_type is not None:
              self._inputs['bucket'] = [bucket_type, bucket]
          return self
docs: Begin a map/reduce operation using a Secondary Index
          query.
  
          :param bucket: The bucket over which to perform the query
          :type bucket: string
          :param index: The index to use for query
          :type index: string
          :param startkey: The start key of index range, or the
             value which all entries must equal
          :type startkey: string, integer
          :param endkey: The end key of index range (if doing a range query)
          :type endkey: string, integer, None
          :param bucket_type: Optional name of a bucket type
          :type bucket_type: string, None
          :rtype: :class:`RiakMapReduce`