pax_global_header00006660000000000000000000000064134024251140014506gustar00rootroot0000000000000052 comment=b9c97812261dcccb44251f8d2204a5cbc627eca5 libsearch-elasticsearch-client-2-0-perl-5.02/000077500000000000000000000000001340242511400207105ustar00rootroot00000000000000libsearch-elasticsearch-client-2-0-perl-5.02/Changes000066400000000000000000000004161340242511400222040ustar00rootroot00000000000000Revision history for Search::Elasticsearch::Client::2_0 5.02 2017-04-02 Updated to work with Search::Elasticsearch 5.02 5.01 2016-10-19 Doc fixes 5.00 2016-10-19 First release of the 2_0 client module for Search::Elasticsearch 5.00 libsearch-elasticsearch-client-2-0-perl-5.02/LICENSE000066400000000000000000000263601340242511400217240ustar00rootroot00000000000000This software is Copyright (c) 2017 by Elasticsearch BV. This is free software, licensed under: The Apache License, Version 2.0, January 2004 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. libsearch-elasticsearch-client-2-0-perl-5.02/MANIFEST000066400000000000000000000027141340242511400220450ustar00rootroot00000000000000# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.009. Changes LICENSE MANIFEST META.json Makefile.PL README lib/Search/Elasticsearch/Client/2_0.pm lib/Search/Elasticsearch/Client/2_0/Bulk.pm lib/Search/Elasticsearch/Client/2_0/Direct.pm lib/Search/Elasticsearch/Client/2_0/Direct/Cat.pm lib/Search/Elasticsearch/Client/2_0/Direct/Cluster.pm lib/Search/Elasticsearch/Client/2_0/Direct/Indices.pm lib/Search/Elasticsearch/Client/2_0/Direct/Nodes.pm lib/Search/Elasticsearch/Client/2_0/Direct/Snapshot.pm lib/Search/Elasticsearch/Client/2_0/Direct/Tasks.pm lib/Search/Elasticsearch/Client/2_0/Role/API.pm lib/Search/Elasticsearch/Client/2_0/Role/Bulk.pm lib/Search/Elasticsearch/Client/2_0/Role/Scroll.pm lib/Search/Elasticsearch/Client/2_0/Scroll.pm lib/Search/Elasticsearch/Client/2_0/TestServer.pm t/Client_2_0/00_print_version.t t/Client_2_0/10_live.t t/Client_2_0/15_conflict.t t/Client_2_0/20_fork_httptiny.t t/Client_2_0/21_fork_lwp.t t/Client_2_0/22_fork_hijk.t t/Client_2_0/30_bulk_add_action.t t/Client_2_0/31_bulk_helpers.t t/Client_2_0/32_bulk_flush.t t/Client_2_0/33_bulk_errors.t t/Client_2_0/34_bulk_cxn_errors.t t/Client_2_0/40_scroll.t t/Client_2_0/50_reindex.t t/Client_2_0/60_auth_httptiny.t t/Client_2_0/61_auth_lwp.t t/author-eol.t t/author-no-tabs.t t/author-pod-syntax.t t/lib/LogCallback.pl t/lib/MockCxn.pm t/lib/bad_cacert.pem t/lib/default_cxn.pl t/lib/es_sync.pl t/lib/es_sync_auth.pl t/lib/es_sync_fork.pl t/lib/index_test_data.pl libsearch-elasticsearch-client-2-0-perl-5.02/META.json000066400000000000000000000043141340242511400223330ustar00rootroot00000000000000{ "abstract" : "Thin client with full support for Elasticsearch 2.x APIs", "author" : [ "Clinton Gormley " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.009, CPAN::Meta::Converter version 2.150010", "license" : [ "apache_2_0" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Search-Elasticsearch-Client-2_0", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::EOL" : "0", "Test::More" : "0.88", "Test::NoTabs" : "0", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Devel::GlobalDestruction" : "0", "Moo" : "0", "Moo::Role" : "0", "Search::Elasticsearch" : "5.02", "Search::Elasticsearch::Role::API" : "0", "Search::Elasticsearch::Role::Client::Direct" : "0", "Search::Elasticsearch::Role::Is_Sync" : "0", "Search::Elasticsearch::Util" : "0", "Try::Tiny" : "0", "namespace::clean" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Data::Dumper" : "0", "IO::Socket::SSL" : "0", "Log::Any::Adapter" : "0", "Log::Any::Adapter::Callback" : "0.09", "POSIX" : "0", "Search::Elasticsearch::Role::Cxn" : "0", "Sub::Exporter" : "0", "Test::Deep" : "0", "Test::Exception" : "0", "Test::More" : "0.98", "lib" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/elastic/elasticsearch-perl/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/elastic/elasticsearch-perl.git", "web" : "https://github.com/elastic/elasticsearch-perl" } }, "version" : "5.02", "x_serialization_backend" : "Cpanel::JSON::XS version 3.0231" } libsearch-elasticsearch-client-2-0-perl-5.02/Makefile.PL000066400000000000000000000044621340242511400226700ustar00rootroot00000000000000# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.009. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Thin client with full support for Elasticsearch 2.x APIs", "AUTHOR" => "Clinton Gormley ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "Search-Elasticsearch-Client-2_0", "LICENSE" => "apache", "NAME" => "Search::Elasticsearch::Client::2_0", "PREREQ_PM" => { "Devel::GlobalDestruction" => 0, "Moo" => 0, "Moo::Role" => 0, "Search::Elasticsearch" => "5.02", "Search::Elasticsearch::Role::API" => 0, "Search::Elasticsearch::Role::Client::Direct" => 0, "Search::Elasticsearch::Role::Is_Sync" => 0, "Search::Elasticsearch::Util" => 0, "Try::Tiny" => 0, "namespace::clean" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Data::Dumper" => 0, "IO::Socket::SSL" => 0, "Log::Any::Adapter" => 0, "Log::Any::Adapter::Callback" => "0.09", "POSIX" => 0, "Search::Elasticsearch::Role::Cxn" => 0, "Sub::Exporter" => 0, "Test::Deep" => 0, "Test::Exception" => 0, "Test::More" => "0.98", "lib" => 0 }, "VERSION" => "5.02", "test" => { "TESTS" => "t/*.t t/Client_2_0/*.t" } ); my %FallbackPrereqs = ( "Data::Dumper" => 0, "Devel::GlobalDestruction" => 0, "IO::Socket::SSL" => 0, "Log::Any::Adapter" => 0, "Log::Any::Adapter::Callback" => "0.09", "Moo" => 0, "Moo::Role" => 0, "POSIX" => 0, "Search::Elasticsearch" => "5.02", "Search::Elasticsearch::Role::API" => 0, "Search::Elasticsearch::Role::Client::Direct" => 0, "Search::Elasticsearch::Role::Cxn" => 0, "Search::Elasticsearch::Role::Is_Sync" => 0, "Search::Elasticsearch::Util" => 0, "Sub::Exporter" => 0, "Test::Deep" => 0, "Test::Exception" => 0, "Test::More" => "0.98", "Try::Tiny" => 0, "lib" => 0, "namespace::clean" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); libsearch-elasticsearch-client-2-0-perl-5.02/README000066400000000000000000000013651340242511400215750ustar00rootroot00000000000000NAME Search::Elasticsearch::Client::2_0 - Thin client with full support for Elasticsearch 2.x APIs VERSION version 5.02 DESCRIPTION The Search::Elasticsearch::Client::2_0 package provides a client compatible with Elasticsearch 2.x. It should be used in conjunction with Search::Elasticsearch as follows: $e = Search::Elasticsearch->new( client => "2_0::Direct" ); See Search::Elasticsearch::Client::2_0::Direct for documentation about how to use the client itself. AUTHOR Clinton Gormley COPYRIGHT AND LICENSE This software is Copyright (c) 2017 by Elasticsearch BV. This is free software, licensed under: The Apache License, Version 2.0, January 2004 libsearch-elasticsearch-client-2-0-perl-5.02/lib/000077500000000000000000000000001340242511400214565ustar00rootroot00000000000000libsearch-elasticsearch-client-2-0-perl-5.02/lib/Search/000077500000000000000000000000001340242511400226635ustar00rootroot00000000000000libsearch-elasticsearch-client-2-0-perl-5.02/lib/Search/Elasticsearch/000077500000000000000000000000001340242511400254355ustar00rootroot00000000000000libsearch-elasticsearch-client-2-0-perl-5.02/lib/Search/Elasticsearch/Client/000077500000000000000000000000001340242511400266535ustar00rootroot00000000000000libsearch-elasticsearch-client-2-0-perl-5.02/lib/Search/Elasticsearch/Client/2_0.pm000066400000000000000000000017011340242511400275700ustar00rootroot00000000000000package Search::Elasticsearch::Client::2_0; our $VERSION='5.02'; use Search::Elasticsearch 5.02 (); 1; =pod =encoding UTF-8 =head1 NAME Search::Elasticsearch::Client::2_0 - Thin client with full support for Elasticsearch 2.x APIs =head1 VERSION version 5.02 =head1 DESCRIPTION The L package provides a client compatible with Elasticsearch 2.x. It should be used in conjunction with L as follows: $e = Search::Elasticsearch->new( client => "2_0::Direct" ); See L for documentation about how to use the client itself. =head1 AUTHOR Clinton Gormley =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2017 by Elasticsearch BV. This is free software, licensed under: The Apache License, Version 2.0, January 2004 =cut __END__ # ABSTRACT: Thin client with full support for Elasticsearch 2.x APIs libsearch-elasticsearch-client-2-0-perl-5.02/lib/Search/Elasticsearch/Client/2_0/000077500000000000000000000000001340242511400272335ustar00rootroot00000000000000libsearch-elasticsearch-client-2-0-perl-5.02/lib/Search/Elasticsearch/Client/2_0/Bulk.pm000066400000000000000000000441221340242511400304710ustar00rootroot00000000000000package Search::Elasticsearch::Client::2_0::Bulk; $Search::Elasticsearch::Client::2_0::Bulk::VERSION = '5.02'; use Moo; with 'Search::Elasticsearch::Client::2_0::Role::Bulk', 'Search::Elasticsearch::Role::Is_Sync'; use Search::Elasticsearch::Util qw(parse_params throw); use Try::Tiny; use namespace::clean; #=================================== sub add_action { #=================================== my $self = shift; my $buffer = $self->_buffer; my $max_size = $self->max_size; my $max_count = $self->max_count; my $max_time = $self->max_time; while (@_) { my @json = $self->_encode_action( splice( @_, 0, 2 ) ); push @$buffer, @json; my $size = $self->_buffer_size; $size += length($_) + 1 for @json; $self->_buffer_size($size); my $count = $self->_buffer_count( $self->_buffer_count + 1 ); $self->flush if ( $max_size and $size >= $max_size ) || ( $max_count and $count >= $max_count ) || ( $max_time and time >= $self->_last_flush + $max_time ); } return 1; } #=================================== sub flush { #=================================== my $self = shift; $self->_last_flush(time); return { items => [] } unless $self->_buffer_size; if ( $self->verbose ) { local $| = 1; print "."; } my $buffer = $self->_buffer; my $results = try { my $res = $self->es->bulk( %{ $self->_bulk_args }, body => $buffer ); $self->clear_buffer; return $res; } catch { my $error = $_; $self->clear_buffer unless $error->is( 'Cxn', 'NoNodes' ); die $error; }; $self->_report( $buffer, $results ); return defined wantarray ? $results : undef; } #=================================== sub reindex { #=================================== my ( $self, $params ) = parse_params(@_); my $src = $params->{source} or throw( 'Param', "Missing required param " ); my $transform = $self->_doc_transformer($params); if ( ref $src eq 'HASH' ) { $src = {%$src}; my $es = delete $src->{es} || $self->es; my $scroll = $es->scroll_helper( search_type => 'scan', size => 500, %$src ); $src = sub { $scroll->refill_buffer; $scroll->drain_buffer; }; print "Reindexing " . $scroll->total . " docs\n" if $self->verbose; } while ( my @docs = grep {defined} $src->() ) { $self->index( grep {$_} map { $transform->($_) } @docs ); } $self->flush; return 1; } 1; =pod =encoding UTF-8 =head1 NAME Search::Elasticsearch::Client::2_0::Bulk - A helper module for the Bulk API and for reindexing =head1 VERSION version 5.02 =head1 SYNOPSIS use Search::Elasticsearch; my $es = Search::Elasticsearch->new; my $bulk = $es->bulk_helper( index => 'my_index', type => 'my_type' ); # Index docs: $bulk->index({ id => 1, source => { foo => 'bar' }}); $bulk->add_action( index => { id => 1, source => { foo=> 'bar' }}); # Create docs: $bulk->create({ id => 1, source => { foo => 'bar' }}); $bulk->add_action( create => { id => 1, source => { foo=> 'bar' }}); $bulk->create_docs({ foo => 'bar' }) # Delete docs: $bulk->delete({ id => 1}); $bulk->add_action( delete => { id => 1 }); $bulk->delete_ids(1,2,3) # Update docs: $bulk->update({ id => 1, script => '...' }); $bulk->add_action( update => { id => 1, script => '...' }); # Manual flush $bulk->flush; # Reindex docs: my $bulk = $es->bulk_helper( index => 'new_index', verbose => 1 ); $bulk->reindex( source => { index => 'old_index' }); =head1 DESCRIPTION This module provides a wrapper for the L method which makes it easier to run multiple create, index, update or delete actions in a single request. It also provides a simple interface for L. The L module acts as a queue, buffering up actions until it reaches a maximum count of actions, or a maximum size of JSON request body, at which point it issues a C request. Once you have finished adding actions, call L to force the final C request on the items left in the queue. This class does L and L. =head1 CREATING A NEW INSTANCE =head2 C my $bulk = $es->bulk_helper( index => 'default_index', # optional type => 'default_type', # optional %other_bulk_params # optional max_count => 1_000, # optional max_size => 1_000_000, # optional max_time => 5, # optional verbose => 0 | 1, # optional on_success => sub {...}, # optional on_error => sub {...}, # optional on_conflict => sub {...}, # optional ); The C method returns a new C<$bulk> object. You must pass your Search::Elasticsearch client as the C argument. The C and C parameters provide default values for C and C, which can be overridden in each action. You can also pass any other values which are accepted by the L method. See L for more information about the other parameters. =head1 FLUSHING THE BUFFER =head2 C $result = $bulk->flush; The C method sends all buffered actions to Elasticsearch using a L request. =head2 Auto-flushing An automatic L is triggered whenever the C, C, or C threshold is breached. This causes all actions in the buffer to be sent to Elasticsearch. =over =item * C The maximum number of actions to allow before triggering a L. This can be disabled by setting C to C<0>. Defaults to C<1,000>. =item * C The maximum size of JSON request body to allow before triggering a L. This can be disabled by setting C to C<0>. Defaults to C<1_000,000> bytes. =item * C The maximum number of seconds to wait before triggering a flush. Defaults to C<0> seconds, which means that it is disabled. B This timeout is only triggered when new items are added to the queue, not in the background. =back =head2 Errors when flushing There are two types of error which can be thrown when L is called, either manually or automatically. =over =item * Temporary Elasticsearch errors A C error like a C error which indicates that your cluster is down. These errors do not clear the buffer, as they can be retried later on. =item * Action errors Individual actions may fail. For instance, a C action will fail if a document with the same C, C and C already exists. These action errors are reported via L. =back =head2 Using callbacks By default, any I (see above) cause warnings to be written to C. However, you can use the C, C and C callbacks for more fine-grained control. All callbacks receive the following arguments: =over =item C<$action> The name of the action, ie C, C, C or C. =item C<$response> The response that Elasticsearch returned for this action. =item C<$i> The index of the action, ie the first action in the flush request will have C<$i> set to C<0>, the second will have C<$i> set to C<1> etc. =back =head3 C my $bulk = $es->bulk_helper( on_success => sub { my ($action,$response,$i) = @_; # do something }, ); The C callback is called for every action that has a successful response. =head3 C my $bulk = $es->bulk_helper( on_conflict => sub { my ($action,$response,$i,$version) = @_; # do something }, ); The C callback is called for actions that have triggered a C error, eg trying to C a document which already exists. The C<$version> argument will contain the version number of the document currently stored in Elasticsearch (if found). =head3 C my $bulk = $es->bulk_helper( on_error => sub { my ($action,$response,$i) = @_; # do something }, ); The C callback is called for any error (unless the C) callback has already been called). =head2 Disabling callbacks and autoflush If you want to be in control of flushing, and you just want to receive the raw response that Elasticsearch sends instead of using callbacks, then you can do so as follows: my $bulk = $es->bulk_helper( max_count => 0, max_size => 0, on_error => undef ); $bulk->add_actions(....); $response = $bulk->flush; =head1 CREATE, INDEX, UPDATE, DELETE =head2 C $bulk->add_action( create => { ...params... }, index => { ...params... }, update => { ...params... }, delete => { ...params... } ); The C method allows you to add multiple C, C, C and C actions to the queue. The first value is the action type, and the second value is the parameters that describe that action. See the individual helper methods below for details. B Parameters like C or C can be specified as C or as C<_index>, so the following two lines are equivalent: index => { index => 'index', type => 'type', id => 1, source => {...}}, index => { _index => 'index', _type => 'type', _id => 1, _source => {...}}, B The C and C parameters can be specified in the params for any action, but if not specified, will default to the C and C values specified in L. These are required parameters: they must be specified either in L or in every action. =head2 C $bulk->create( { index => 'custom_index', source => { doc body }}, { type => 'custom_type', id => 1, source => { doc body }}, ... ); The C helper method allows you to add multiple C actions. It accepts the same parameters as L except that the document body should be passed as the C or C<_source> parameter, instead of as C. =head2 C $bulk->create_docs( { doc body }, { doc body }, ... ); The C helper is a shorter form of L which can be used when you are using the default C and C as set in L and you are not specifying a custom C per document. In this case, you can just pass the individual document bodies. =head2 C $bulk->index( { index => 'custom_index', source => { doc body }}, { type => 'custom_type', id => 1, source => { doc body }}, ... ); The C helper method allows you to add multiple C actions. It accepts the same parameters as L except that the document body should be passed as the C or C<_source> parameter, instead of as C. =head2 C $bulk->delete( { index => 'custom_index', id => 1}, { type => 'custom_type', id => 2}, ... ); The C helper method allows you to add multiple C actions. It accepts the same parameters as L. =head2 C $bulk->delete_ids(1,2,3...) The C helper method can be used when all of the documents you want to delete have the default C and C as set in L. In this case, all you have to do is to pass in a list of IDs. =head2 C $bulk->update( { id => 1, doc => { partial doc }, doc_as_upsert => 1 }, { id => 2, lang => 'mvel', script => { script } upsert => { upsert doc } }, ... ); The C helper method allows you to add multiple C actions. It accepts the same parameters as L. An update can either use a I which gets merged with an existing doc (example 1 above), or can use a C