/** * Search a secondary index * @author Eric Stevens <*****@*****.**> * @param string $indexName - The name of the index to search * @param string $indexType - The type of index ('int' or 'bin') * @param string|int $startOrExact * @param string|int optional $end * @param bool optional $dedupe - whether to eliminate duplicate entries if any * @return array of RiakLinks */ function indexSearch($indexName, $indexType, $startOrExact, $end = NULL, $dedupe = false) { $url = RiakUtils::buildIndexPath($this->client, $this, "{$indexName}_{$indexType}", $startOrExact, $end); $response = RiakUtils::httpRequest('GET', $url); $obj = new RiakObject($this->client, $this, NULL); $obj->populate($response, array(200)); if (!$obj->exists()) { throw new Exception("Error searching index."); } $data = $obj->getData(); $keys = array_map("urldecode", $data["keys"]); $seenKeys = array(); foreach ($keys as $id => &$key) { if ($dedupe) { if (isset($seenKeys[$key])) { unset($keys[$id]); continue; } $seenKeys[$key] = true; } $key = new RiakLink($this->name, $key); $key->client = $this->client; } return $keys; }
/** * Retrieve an associative array of all bucket properties. * @return Array */ function getProperties() { # Run the request... $params = array('props' => 'true', 'keys' => 'false'); $url = RiakUtils::buildRestPath($this->client, $this, NULL, NULL, $params); $response = RiakUtils::httpRequest('GET', $url); # Use a RiakObject to interpret the response, we are just interested in the value. $obj = new RiakObject($this->client, $this, NULL); $obj->populate($response, array(200)); if (!$obj->exists()) { throw Exception("Error getting bucket properties."); } $props = $obj->getData(); $props = $props["props"]; return $props; }