line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
90525
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
416
|
use Catmandu; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
5
|
1
|
|
|
1
|
|
423
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
246
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
685
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#options/arguments |
11
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
12
|
|
|
|
|
|
|
has store_name => (fix_opt => 1, init_arg => 'store'); |
13
|
|
|
|
|
|
|
has bag_name => (fix_opt => 1, init_arg => 'bag'); |
14
|
|
|
|
|
|
|
has limit => (fix_opt => 1, init_arg => undef, default => sub {20}); |
15
|
|
|
|
|
|
|
has start => (fix_opt => 1, init_arg => undef, default => sub {0}); |
16
|
|
|
|
|
|
|
has sort => (fix_opt => 1, init_arg => undef, default => sub {''}); |
17
|
|
|
|
|
|
|
has store_args => (fix_opt => 'collect'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#internal |
20
|
|
|
|
|
|
|
has store => (is => 'lazy', init_arg => undef, builder => '_build_store'); |
21
|
|
|
|
|
|
|
has bag => (is => 'lazy', init_arg => undef, builder => '_build_bag'); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $self = $_[0]; |
24
|
|
|
|
|
|
|
Catmandu->store($self->store_name, %{$self->store_args}); |
25
|
5
|
|
|
5
|
|
42
|
} |
26
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
23
|
|
27
|
|
|
|
|
|
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
defined $self->bag_name |
29
|
|
|
|
|
|
|
? $self->store->bag($self->bag_name) |
30
|
5
|
|
|
5
|
|
40
|
: $self->store->bag; |
31
|
5
|
100
|
|
|
|
79
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
my $bag = $self->bag; |
35
|
|
|
|
|
|
|
my $limit = $self->limit; |
36
|
|
|
|
|
|
|
my $start = $self->start; |
37
|
5
|
|
|
5
|
|
40
|
my $sort = $self->sort; |
38
|
5
|
|
|
|
|
63
|
as_path($self->path)->updater( |
39
|
5
|
|
|
|
|
28
|
sub { |
40
|
5
|
|
|
|
|
9
|
my $val = $_[0]; |
41
|
5
|
|
|
|
|
10
|
my $hits = $bag->search( |
42
|
|
|
|
|
|
|
query => $val, |
43
|
|
|
|
|
|
|
start => $start, |
44
|
5
|
|
|
5
|
|
9
|
limit => $limit, |
45
|
5
|
|
|
|
|
80
|
sort => $sort |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
+{ |
48
|
|
|
|
|
|
|
start => $start, |
49
|
|
|
|
|
|
|
limit => $limit, |
50
|
|
|
|
|
|
|
total => $hits->total, |
51
|
|
|
|
|
|
|
hits => $hits->to_array |
52
|
5
|
|
|
|
|
1868
|
}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
5
|
|
|
|
|
17
|
|
59
|
|
|
|
|
|
|
Catmandu::Fix::search_in_store - use the value as query, and replace it by a search object |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNTAX |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
search_in_store(path) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
search_in_store(path,store: 'store', bag: 'bag', limit: 0, start: 0, sort: 'title desc') |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 RETURN VALUE |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
start: 0, |
71
|
|
|
|
|
|
|
limit: 0, |
72
|
|
|
|
|
|
|
hits: [], |
73
|
|
|
|
|
|
|
total: 1000 |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
cf. L<Catmandu::Hits> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 PARAMETERS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 path |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
The location in the perl hash where the query is stored. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
See L<Catmandu::Fix/"PATHS"> for more information about paths. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 store |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The name of the store. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This store MUST be an implementation of L<Catmandu::Searchable>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
There are several ways to refer to a store: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
* by full package name ( e.g. 'Catmandu::Store::Solr' ) |
95
|
|
|
|
|
|
|
* by short package name ( e.g. 'Solr' ) |
96
|
|
|
|
|
|
|
* by name defined in the Catmandu configuration |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
See L<Catmandu/store-NAME> for more information. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Default is 'default'. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 bag |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Name of bag. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Default is 'data'. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 limit |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
only return $limit number of records. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 start |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
offset of records to return |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 sort |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sort records before slicing them. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This parameter is store specific. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 OTHER PARAMETERS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
other parameters are given to the contructor of the L<Catmandu::Store> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
e.g. catmandu.yml: |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
store: |
130
|
|
|
|
|
|
|
catalog: |
131
|
|
|
|
|
|
|
package: "Catmandu::Store::Solr" |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
e.g. fix: |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
search_in_store('foo.query', store:'catalog', bag: 'data', url: 'http://localhost:8983/solr/catalog') |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 EXAMPLES |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#search in Catmandu->store->bag, and store first 20 results in the foo.query.hits |
140
|
|
|
|
|
|
|
search_in_store('foo.query') |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#search in Catmandu->store->bag, and store first 20 results in the foo.query.hits |
143
|
|
|
|
|
|
|
search_in_store('foo.query', store:'default') |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#search in Catmandu->store->bag; limit number of results to 10 |
146
|
|
|
|
|
|
|
search_in_store('foo.query', store:'default', limit: 10) |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
#search in Catmandu->store->bag; limit number of result to 10, starting from 15 |
149
|
|
|
|
|
|
|
search_in_store('foo.query', store:'default', limit: 10, start: 15) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#search in Catmandu->store->bag('persons'); sort by year descending, and by title ascending |
152
|
|
|
|
|
|
|
search_in_store('foo.query', store:'default', bag:'persons', sort: 'year desc,title asc') |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHORS |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Nicolas Franck C<< <nicolas.franck at ugent.be> >> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SEE ALSO |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L<Catmandu::Fix> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L<Catmandu::Store> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |