From 9e4c681beae5a7a223cf84d411a12a1ccb3daa6f Mon Sep 17 00:00:00 2001 From: gmaurice Date: Wed, 22 Jun 2011 19:27:21 +0200 Subject: add basic support of riaksearch (need to see what is missed) --- lib/Net/Riak/Search.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/Net/Riak/Search.pm (limited to 'lib/Net/Riak/Search.pm') diff --git a/lib/Net/Riak/Search.pm b/lib/Net/Riak/Search.pm new file mode 100644 index 0000000..ac9f059 --- /dev/null +++ b/lib/Net/Riak/Search.pm @@ -0,0 +1,15 @@ +package Net::Riak::Search; + +# ABSTRACT: the riaklink object represents a link from one Riak object to another + +use Moose; + +with 'Net::Riak::Role::Base' => {classes => + [{name => 'client', required => 0},]}; + +sub search { + my ($self, $params) = @_; + $self->client->search($params); +}; + +1; -- cgit v1.2.3 From ade1fc13ec613d2318a9c3517bc40837d99f4d99 Mon Sep 17 00:00:00 2001 From: gmaurice Date: Sat, 2 Jul 2011 00:03:55 +0200 Subject: allow to setup indexing on a bucket via precommit add tests for riaksearch --- lib/Net/Riak/Search.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/Net/Riak/Search.pm') diff --git a/lib/Net/Riak/Search.pm b/lib/Net/Riak/Search.pm index ac9f059..8cf42b7 100644 --- a/lib/Net/Riak/Search.pm +++ b/lib/Net/Riak/Search.pm @@ -1,7 +1,5 @@ package Net::Riak::Search; -# ABSTRACT: the riaklink object represents a link from one Riak object to another - use Moose; with 'Net::Riak::Role::Base' => {classes => @@ -12,4 +10,9 @@ sub search { $self->client->search($params); }; +sub setup_indexing { + my ($self, $bucket) = @_; + $self->client->setup_indexing($bucket); +}; + 1; -- cgit v1.2.3 From 08cf0c72671e94086352b03683e1ad57348bee1f Mon Sep 17 00:00:00 2001 From: gmaurice Date: Thu, 7 Jul 2011 13:19:06 +0200 Subject: documentation added for search --- lib/Net/Riak/Search.pm | 69 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'lib/Net/Riak/Search.pm') diff --git a/lib/Net/Riak/Search.pm b/lib/Net/Riak/Search.pm index 8cf42b7..a6282de 100644 --- a/lib/Net/Riak/Search.pm +++ b/lib/Net/Riak/Search.pm @@ -1,7 +1,8 @@ package Net::Riak::Search; - use Moose; +#ABSTRACT: Search interface + with 'Net::Riak::Role::Base' => {classes => [{name => 'client', required => 0},]}; @@ -16,3 +17,69 @@ sub setup_indexing { }; 1; + + +=head1 SYNOPSIS + + my $client = Net::Riak->new(...); + my $bucket = $client->bucket('foo'); + + # retrieve an existing object + my $obj1 = $bucket->get('foo'); + + # create/store a new object + my $obj2 = $bucket->new_object('foo2', {...}); + $object->store; + + $bucket->delete_object($key, 3); # optional w val + +=head1 DESCRIPTION + +L allows you to enable indexing documents for a given bucket and querying/searching the index. + +=head2 METHODS + +=head3 setup_indexing + + $client->setup_indexing('bucket_name'); + +Does the same as : + + curl -X PUT -H "content-type:application/json" http://localhost:8098/riak/bucket_name -d '{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}' + +but takes in account previouses precommits. + +=head3 search + + my $response = $client->search( + index => 'bucket_name', + q => 'field:value' + ); + # is the same as : + my $response = $client->search( + q => 'bucket_name.field:value' + ); + +Search the index + +=over 4 + +=item wt => 'XML|JSON' + +defines the response format (XML is the default value as for Solr/Lucene) + +=item q + +the query string + +=item index + +is the default index you want to query, if no index is provided you have to add it as a prefix of the fields in the query string + +=item rows + +is the number of documents you want to be returned in the response + +=back + +More parameters are available, just check at L \ No newline at end of file -- cgit v1.2.3 From 94209555eaa12357b177f36be40497a9b0d83ed6 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Thu, 7 Jul 2011 13:23:39 +0200 Subject: perltidy + whitespaces removed Signed-off-by: franck cuny --- lib/Net/Riak/Search.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/Net/Riak/Search.pm') diff --git a/lib/Net/Riak/Search.pm b/lib/Net/Riak/Search.pm index a6282de..ee2ed57 100644 --- a/lib/Net/Riak/Search.pm +++ b/lib/Net/Riak/Search.pm @@ -1,4 +1,5 @@ -package Net::Riak::Search; +package +Net::Riak::Search; use Moose; #ABSTRACT: Search interface @@ -18,7 +19,6 @@ sub setup_indexing { 1; - =head1 SYNOPSIS my $client = Net::Riak->new(...); @@ -45,8 +45,8 @@ L allows you to enable indexing documents for a given bucket Does the same as : - curl -X PUT -H "content-type:application/json" http://localhost:8098/riak/bucket_name -d '{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}' - + curl -X PUT -H "content-type:application/json" http://localhost:8098/riak/bucket_name -d '{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}' + but takes in account previouses precommits. =head3 search @@ -82,4 +82,4 @@ is the number of documents you want to be returned in the response =back -More parameters are available, just check at L \ No newline at end of file +More parameters are available, just check at L -- cgit v1.2.3