Elastic-Model
view release on metacpan or search on metacpan
lib/Elastic/Model/Index.pm view on Meta::CPAN
=over
=item size
The C<size> parameter defaults to 1,000 and controls how many documents
are pulled from C<$domain> in each request. See L<Elastic::Model::View/size>.
B<Note:> documents are pulled from the C<domain>/C<view> using
L<Elastic::Model::View/scan()>, which can pull a maximum of
L<size|Elastic::Model::View/size> C<* number_of_primary_shards> in a single
request. If you have large docs or underpowered servers, you may want to
change the C<size> parameter.
=item bulk_size
The C<bulk_size> parameter defaults to C<size> and controls how many documents
are indexed into the new domain in a single bulk-indexing request.
=item scan
C<scan> is the same as L<Elastic::Model::View/scan> - it controls how long
Elasticsearch should keep the "scroll" live between requests. Defaults to
'2m'. Increase this if the reindexing process is slow and you get
scroll timeouts.
=item repoint_uids
If true (the default), L</repoint_uids()> will be called automatically to
update any L<UIDs|Elastic::Model::UID> (which point at the old index) in
indices other than the ones currently being reindexed.
=item transform
If you need to change the structure/data of your doc while reindexing, you
can pass a C<transform> coderef. This will be called before any changes
have been made to the doc, and should return the new doc. For instance,
to convert the single-value C<tag> field to an array of C<tags>:
$index->reindex(
'new_index',
'transform' => sub {
my $doc = shift;
$doc->{_source}{tags} = [ delete $doc->{_source}{tag} ];
return $doc
}
);
=item on_conflict / on_error
If you are indexing to the new index at the same time as you
are reindexing, you may get document conflicts. You can handle the conflicts
with a coderef callback, or ignore them by by setting C<on_conflict> to
C<'IGNORE'>:
$index->reindex( 'myapp_v2', on_conflict => 'IGNORE' );
Similarly, you can pass an C<on_error> handler which will handle other errors,
or all errors if no C<on_conflict> handler is defined.
See L<Search::Elasticsearch::Bulk/Using-callbacks> for more.
=item uid_on_conflict / uid_on_error
These work in the same way as the C<on_conflict> or C<on_error> handlers,
but are passed to L</repoint_uids()> if C<repoint_uids> is true.
=item quiet
By default, L</reindex()> prints out progress information. To silence this,
set C<quiet> to true:
$index->reindex( 'myapp_v2', quiet => 1 );
=back
=head2 repoint_uids()
$index->repoint_uids(
uids => [ ['myapp_v1','user',10],['myapp_v1','user',12]...],
exclude => ['myapp_v2'],
scan => '2m',
size => 1000,
bulk_size => 1000,
quiet => 0,
on_conflict => sub {...} | 'IGNORE'
on_error => sub {...} | 'IGNORE'
);
The purpose of L</repoint_uids()> is to update stale L<UID|Elastic::Model::UID>
attributes to point to a new index. It is called automatically from
L</reindex()>.
Parameters:
=over
=item uids
C<uids> is a hash ref the stale L<UIDs|Elastic::Model::UID> which should be
updated.
For instance: you have reindexed C<myapp_v1> to C<myapp_v2>, but domain
C<other> has documents with UIDs which point to C<myapp_v1>. You
can updated these by passing a list of the old UIDs, as follows:
$index = $namespace->index('myapp_v2');
$index->repoint_uids(
uids => { # index
myapp_v1 => { # type
user => {
1 => 1, # ids
2 => 1,
}
}
}
);
=item exclude
By default, all indices known to the L<model|Elastic::Model::Role::Model> are
updated. You can exclude indices with:
$index->repoint_uids(
uids => \@uids,
exclude => ['index_1', ...]
);
=item size
This is the same as the C<size> parameter to L</reindex()>.
=item bulk_size
This is the same as the C<bulk_size> parameter to L</reindex()>.
=item scan
This is the same as the C<scan> parameter to L</reindex()>.
=item quiet
This is the same as the C<quiet> parameter to L</reindex()>.
=item on_conflict / on_error
These are the same as the C<uid_on_conflict> and C<uid_on_error> handlers
in L</reindex()>.
=back
=head2 doc_updater()
$coderef = $index->doc_updater( $doc_updater, $uid_updater );
L</doc_updater()> is used by L</reindex()> and L</repoint_uids()> to update
the top-level doc and any UID attributes with callbacks.
The C<$doc_updater> receives the C<$doc> as its only attribute, and should
return the C<$doc> after making any changes:
$doc_updater = sub {
my ($doc) = @_;
$doc->{_index} = 'foo';
return $doc
};
The C<$uid_updater> receives the UID as its only attribute:
$uid_updater = sub {
my ($uid) = @_;
$uid->{index} = 'foo'
};
=head1 IMPORTED ATTRIBUTES
Attributes imported from L<Elastic::Model::Role::Index>
=head2 L<namespace|Elastic::Model::Role::Index/namespace>
=head2 L<name|Elastic::Model::Role::Index/name>
=head1 IMPORTED METHODS
Methods imported from L<Elastic::Model::Role::Index>
=head2 L<close()|Elastic::Model::Role::Index/close()>
=head2 L<open()|Elastic::Model::Role::Index/open()>
=head2 L<refresh()|Elastic::Model::Role::Index/refresh()>
=head2 L<delete()|Elastic::Model::Role::Index/delete()>
=head2 L<update_analyzers()|Elastic::Model::Role::Index/update_analyzers()>
=head2 L<update_settings()|Elastic::Model::Role::Index/update_settings()>
=head2 L<delete_mapping()|Elastic::Model::Role::Index/delete_mapping()>
=head2 L<is_alias()|Elastic::Model::Role::Index/is_alias()>
=head2 L<is_index()|Elastic::Model::Role::Index/is_index()>
=head1 SEE ALSO
=over
=item *
L<Elastic::Model::Role::Index>
=item *
L<Elastic::Model::Alias>
=item *
( run in 0.742 second using v1.01-cache-2.11-cpan-39bf76dae61 )