summary refs log tree commit diff
path: root/lib/Net/Riak/Role
diff options
context:
space:
mode:
authorMainframe2008 <thg.bot@gmail.com>2013-02-26 08:44:28 +0100
committerMainframe2008 <thg.bot@gmail.com>2013-02-26 08:44:28 +0100
commit1b442767f0bc92b98c3a398dde02dae6212ecd1c (patch)
tree103131ad787226886342fa39d44317ce9438c5e1 /lib/Net/Riak/Role
parentAdd documentation for secondary indexes (diff)
downloadnet-riak-1b442767f0bc92b98c3a398dde02dae6212ecd1c.tar.gz
*Added secondary index support using method names from the riak python
client.
* Added tests for secondary indexes
* Added documentation
Diffstat (limited to 'lib/Net/Riak/Role')
-rw-r--r--lib/Net/Riak/Role/REST/Object.pm4
-rw-r--r--lib/Net/Riak/Role/REST/Search.pm28
2 files changed, 19 insertions, 13 deletions
diff --git a/lib/Net/Riak/Role/REST/Object.pm b/lib/Net/Riak/Role/REST/Object.pm
index 859e06b..545e4e0 100644
--- a/lib/Net/Riak/Role/REST/Object.pm
+++ b/lib/Net/Riak/Role/REST/Object.pm
@@ -103,8 +103,8 @@ sub populate_object {
     
     $HTTP::Headers::TRANSLATE_UNDERSCORE = 0;
     foreach ( $http_response->header_field_names ) {
-    	next unless /^X-Riak-Index-(.+_bin)/;
-    	$obj->i2index({ lc($1) => $http_response->header($_) })
+    	next unless /^X-Riak-Index-(.+_bin)$/ || /^X-Riak-Index-(.+_int)$/;
+    	$obj->add_index(lc($1),  $http_response->header($_) )
     }
     $HTTP::Headers::TRANSLATE_UNDERSCORE = 1;
 
diff --git a/lib/Net/Riak/Role/REST/Search.pm b/lib/Net/Riak/Role/REST/Search.pm
index 7e74af5..f813578 100644
--- a/lib/Net/Riak/Role/REST/Search.pm
+++ b/lib/Net/Riak/Role/REST/Search.pm
@@ -74,21 +74,27 @@ sub setup_indexing {
     JSON::decode_json($http_response->content);
 }
 
-sub i2search {
-	my $self = shift;
-	my %params = @_;
+sub index {
+	my ($self, $bucket,$index,$first, $last) = @_;
+	
 	my $request;
+	my @req = ();
 	
 	my $org_prefix = $self->prefix;
-	
-	$request = $self->new_request('GET', [
+	if ( defined($bucket) && defined($index) && defined($first) )
+	{
+		@req = (
 			'buckets',
-			$params{bucket},
-			'index',
-			$params{index},
-			$params{key}
-			]
-	);
+				$bucket,
+				'index',
+				$index,
+				$first
+			);
+	
+		if ( defined($last) ) { push(@req, $last); }
+	} 
+	
+	$request = $self->new_request('GET', [ @req ] );
 	
 	my $http_response = $self->send_request($request);
 	JSON::decode_json($http_response->content)->{keys};