Skip to content

Commit

Permalink
support passing time/size params for the scroller
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyn committed Mar 1, 2017
1 parent 471c832 commit 05cb651
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions lib/MetaCPAN/Client.pm
Expand Up @@ -605,6 +605,30 @@ we can't to begin with (like non-leaf fields that hold a structure)
my $module = $mcpan->all('releases', { _source => "stat" });
=head2 scroller_time
Note: please use with caution.
This parameter will set the max. lifetime of the ElasticSearch scroller
on the server (default = '5m').
Normally you do not need to set this value (as tweaking this value can
affect resources on the server);
in case you do - you probably need to check the efficiency of your
code/queries (feel free to reach out to us for assistance).
my $module = $mcpan->all('releases', { scroller_time => "3m" });
=head2 scroller_size
Note: please use with caution.
This parameter will set the buffer size to be pulled from ElasticSearch
when scrolling (default = 1000).
This will affect query performance and memory usage, but you will still
get an iterator back to fetch one object at a time.
my $module = $mcpan->all('releases', { scroller_size => 500 });
=head1 SEARCH SPEC
The hash-based search spec is common to many searches. It is quite
Expand Down
6 changes: 5 additions & 1 deletion lib/MetaCPAN/Client/Request.pm
Expand Up @@ -132,9 +132,13 @@ sub ssearch {
my $args = shift;
my $params = shift;

my $time = delete $params->{'scroller_time'} || '5m';
my $size = delete $params->{'scroller_size'} || '1000';

my $scroller = MetaCPAN::Client::Scroll->new(
ua => $self->ua,
size => 1000,
size => $size,
time => $time,
base_url => $self->base_url,
type => $type,
body => $self->_build_body($args, $params),
Expand Down

0 comments on commit 05cb651

Please sign in to comment.