Permalink
Browse files

Fixed a bug in reindex() which was loading all documents into memory,…

… rather than processing them in blocks
  • Loading branch information...
1 parent 2829d6b commit 3743ffbf2e8c70f038feab3f72b3b3582739f88c @clintongormley committed Aug 9, 2012
Showing with 15 additions and 13 deletions.
  1. +14 −12 lib/Elastic/Model/Index.pm
  2. +1 −1 lib/Elastic/Model/Role/Model.pm
@@ -71,12 +71,13 @@ sub reindex {
my $source = $model->view->domain($domain)->size($size)->scan($scan);
$model->es->reindex(
- source => $source->as_elements,
- quiet => !$verbose,
- transform => $updater,
- bulk_size => $bulk_size,
- on_conflict => $args{on_conflict},
- on_error => $args{on_error},
+ source => $source,
+ _method_name => 'shift_element',
+ quiet => !$verbose,
+ transform => $updater,
+ bulk_size => $bulk_size,
+ on_conflict => $args{on_conflict},
+ on_error => $args{on_error},
);
return 1 unless $args{repoint_uids};
@@ -158,12 +159,13 @@ sub repoint_uids {
my $source = $view->filterb( \@clauses )->scan($scan);
$model->es->reindex(
- source => $source->as_elements,
- bulk_size => $bulk_size,
- quiet => 1,
- transform => $updater,
- on_conflict => $args{on_conflict},
- on_error => $args{on_error},
+ source => $source,
+ _method_name => 'shift_element',
+ bulk_size => $bulk_size,
+ quiet => 1,
+ transform => $updater,
+ on_conflict => $args{on_conflict},
+ on_error => $args{on_error},
);
}
@@ -3,7 +3,7 @@ package Elastic::Model::Role::Model;
use Moose::Role;
use Carp;
use Elastic::Model::Types qw(ES ES_UniqueKey);
-use ElasticSearch 0.57 ();
+use ElasticSearch 0.58 ();
use ElasticSearchX::UniqueKey 0.03 ();
use Class::Load qw(load_class);
use Moose::Util qw(does_role);

0 comments on commit 3743ffb

Please sign in to comment.