line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of ElasticSearchX-Model |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2019 by Moritz Onken. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The (three-clause) BSD License |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package ElasticSearchX::Model::Scroll; |
11
|
|
|
|
|
|
|
$ElasticSearchX::Model::Scroll::VERSION = '2.0.1'; |
12
|
2
|
|
|
2
|
|
16
|
use Moose; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
14
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
12732
|
use ElasticSearchX::Model::Document::Types qw(ESScroll); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
21
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has scroll => ( is => 'ro', isa => 'Str', required => 1, default => '1m' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has set => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => 'ElasticSearchX::Model::Document::Set', |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
handles => [qw(type index inflate inflate_result)], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has _scrolled_search => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => ESScroll, |
28
|
|
|
|
|
|
|
lazy_build => 1, |
29
|
|
|
|
|
|
|
handles => { |
30
|
|
|
|
|
|
|
_next => 'next', |
31
|
|
|
|
|
|
|
total => 'total', |
32
|
|
|
|
|
|
|
max_score => 'max_score' |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has qs => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => 'HashRef', |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _build__scrolled_search { |
42
|
0
|
|
|
0
|
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
$self->set->es->scroll_helper( |
44
|
|
|
|
|
|
|
body => $self->set->_build_query, |
45
|
|
|
|
|
|
|
scroll => $self->scroll, |
46
|
|
|
|
|
|
|
index => $self->index->name, |
47
|
|
|
|
|
|
|
type => $self->type->short_name, |
48
|
0
|
0
|
|
|
|
|
%{ $self->qs || {} }, |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub next { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
0
|
0
|
|
|
|
|
return undef unless ( my $next = $self->_next ); |
55
|
0
|
0
|
|
|
|
|
return $next unless ( $self->inflate ); |
56
|
0
|
|
|
|
|
|
return $self->inflate_result($next); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
ElasticSearchX::Model::Scroll |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 2.0.1 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $iterator = $twitter->type('tweet')->scroll( '5m' ); |
78
|
|
|
|
|
|
|
while(my $tweet = $iterator->next) { |
79
|
|
|
|
|
|
|
# do something with $tweet |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $iterator = $twitter->type('tweet')->raw->scroll; |
83
|
|
|
|
|
|
|
$iterator->max_score; |
84
|
|
|
|
|
|
|
$iterator->total; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 scroll |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This string indicated how long ElasticSearch should keep the scrolled |
91
|
|
|
|
|
|
|
search around. This attribute is set by passing it to |
92
|
|
|
|
|
|
|
L<ElasticSearchX::Model::Document::Set/scroll>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 set |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The L<ElasticSearchX::Model::Document::Set> this instance was build |
97
|
|
|
|
|
|
|
from. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 METHODS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 total |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 eof |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 max_score |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Delegates to L<Elasticsearch::Scroll>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 next |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the next result in the search. If you set the query to not |
112
|
|
|
|
|
|
|
inflate the results (e.g. using L<ElasticSearchX::Model::Document::Set/raw>) |
113
|
|
|
|
|
|
|
it returns the raw HashRef, otherwise the result is inflated to |
114
|
|
|
|
|
|
|
the correct document class. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Moritz Onken |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Moritz Onken. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software, licensed under: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The (three-clause) BSD License |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |