line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Store::Solr; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1315
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
104085
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
242
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
686
|
use WebService::Solr; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Store::Solr::Bag; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Store'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Catmandu::Store::Solr - A searchable store backed by Solr |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.0204 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.0204'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Catmandu::Store::Solr; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $store = Catmandu::Store::Solr->new(url => 'http://localhost:8983/solr' ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $obj1 = $store->bag->add({ name => 'Patrick' }); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
printf "obj1 stored as %s\n" , $obj1->{_id}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Force an id in the store |
33
|
|
|
|
|
|
|
my $obj2 = $store->bag->add({ _id => 'test123' , name => 'Nicolas' }); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Commit all changes |
36
|
|
|
|
|
|
|
$store->bag->commit; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $obj3 = $store->bag->get('test123'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$store->bag->delete('test123'); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$store->bag->delete_all; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# All bags are iterators |
45
|
|
|
|
|
|
|
$store->bag->each(sub { ... }); |
46
|
|
|
|
|
|
|
$store->bag->take(10)->each(sub { ... }); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Some stores can be searched |
49
|
|
|
|
|
|
|
my $hits = $store->bag->search(query => 'name:Patrick'); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has url => (is => 'ro', default => sub { 'http://localhost:8983/solr' }); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
has solr => ( |
56
|
|
|
|
|
|
|
is => 'ro', |
57
|
|
|
|
|
|
|
lazy => 1, |
58
|
|
|
|
|
|
|
builder => '_build_solr', |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _build_solr { |
62
|
|
|
|
|
|
|
WebService::Solr->new($_[0]->url, {autocommit => 0, default_params => {wt => 'json'}}); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SUPPORT |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Solr schemas need to support '_id' and '_bag' record fields to be able to |
68
|
|
|
|
|
|
|
store Catmandu items. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 METHODS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 new(url => $solr_url) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Create a new Catmandu::Store::Solr store. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 AUTHOR |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Patrick Hochstenbach, C<< >> |
83
|
|
|
|
|
|
|
Nicolas Steenlant, C<< >> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
88
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
89
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |