1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
package
Net::Riak::Search;
use Moose;
#ABSTRACT: Search interface
with 'Net::Riak::Role::Base' => {classes =>
[{name => 'client', required => 0},]};
sub search {
my ($self, $params) = @_;
$self->client->search($params);
};
sub setup_indexing {
my ($self, $bucket) = @_;
$self->client->setup_indexing($bucket);
};
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
# Secondary index setup
my $obj3 = $bucket->new_object('foo3', {...});
$obj3->add_index('index', 'first');
$obj3->store;
my @keys = $client->index('bucket', 'myindex_bin', 'first_value' [, 'last_value'] );
=head1 DESCRIPTION
L<Net::Riak::Search> 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
=item add_index
add secondary index to object
= item remove_index
remove secondary index from object
=item index
Find keys via secondary index.
=back
More parameters are available, just check at L<http://wiki.basho.com/Riak-Search---Querying.html#Querying-via-the-Solr-Interface>
|