@@ -86,6 +86,12 @@ has skip_existing_mapping => (
86
86
documentation => ' do NOT copy mappings other than patch_mapping' ,
87
87
);
88
88
89
+ has copy_from_index => (
90
+ is => ' ro' ,
91
+ isa => Str,
92
+ documentation => ' index to copy type from' ,
93
+ );
94
+
89
95
has copy_to_index => (
90
96
is => ' ro' ,
91
97
isa => Str,
@@ -336,9 +342,13 @@ sub create_index {
336
342
337
343
sub copy_type {
338
344
my ( $self , $index , $type ) = @_ ;
339
- $index //= $self -> copy_to_index;
345
+ my $from_index = $self -> copy_from_index
346
+ or die " can't copy without a source index" ;
347
+ $index //= $self -> copy_to_index
348
+ or die " can't copy without a destination index" ;
340
349
341
- $self -> _check_index_exists( $index , EXPECTED );
350
+ $self -> _check_index_exists( $from_index , EXPECTED );
351
+ $self -> _check_index_exists( $index , EXPECTED );
342
352
$type //= $self -> arg_copy_type;
343
353
$type or die " can't copy without a type\n " ;
344
354
@@ -358,7 +368,7 @@ sub copy_type {
358
368
};
359
369
}
360
370
361
- return $self -> _copy_slice( $query , $index , $type ) if $query ;
371
+ return $self -> _copy_slice( $query , $from_index , $ index , $type ) if $query ;
362
372
363
373
# else ... do copy by monthly slices
364
374
@@ -374,7 +384,7 @@ sub copy_type {
374
384
375
385
log_info {" copying data for month: $gte " };
376
386
eval {
377
- $self -> _copy_slice( $q , $index , $type );
387
+ $self -> _copy_slice( $q , $from_index , $ index , $type );
378
388
1;
379
389
} or do {
380
390
my $err = $@ || ' zombie error' ;
@@ -384,12 +394,12 @@ sub copy_type {
384
394
}
385
395
386
396
sub _copy_slice {
387
- my ( $self , $query , $index , $type ) = @_ ;
397
+ my ( $self , $query , $from_index , $ index , $type ) = @_ ;
388
398
389
399
my $scroll = $self -> es-> scroll_helper(
390
400
size => 250,
391
401
scroll => ' 10m' ,
392
- index => $self -> index -> name ,
402
+ index => $from_index ,
393
403
type => $type ,
394
404
body => {
395
405
query => $query ,
0 commit comments