Elasticsearch/Client/7_0/Direct.pm

filter: Statementstmt 54.0% 40 / 74 Branchbran n/a Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 10.3% 3 / 29 Podpod 100% 2 / 2 totaltotal 37.1% 45 / 121 CC 5 SCAR 10.6
CC
5
Cov
48%
_build__bulk_class
6.0
_build__scroll_class
6.0
bulk_helper
6.0
CRAP 2.9
« Elasticsearch/Client/7_0/Role/API.pm ↑ Summary Elasticsearch/Role/CxnPool.pm »
1 # Licensed to Elasticsearch B.V under one or more agreements.
2 # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3 # See the LICENSE file in the project root for more information
4  
5 package Search::Elasticsearch::Client::7_0::Direct;
6 55 $Search::Elasticsearch::Client::7_0::Direct::VERSION = '7.30_1'; # TRIAL
7  
8 55 $Search::Elasticsearch::Client::7_0::Direct::VERSION = '7.301';
9 55 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 55 with 'Search::Elasticsearch::Client::7_0::Role::API';
11 55 with 'Search::Elasticsearch::Role::Client::Direct';
12  
13 55 ▶use Search::Elasticsearch::Util qw(parse_params is_compat);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 55 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub _namespace {__PACKAGE__}
Subroutine _namespace: not called CC=1 SCAR=6.9
17  
18 55 has 'cluster' => ( is => 'lazy', init_arg => undef );
19 55 has 'nodes' => ( is => 'lazy', init_arg => undef );
20 55 has 'indices' => ( is => 'lazy', init_arg => undef );
21 55 has 'ingest' => ( is => 'lazy', init_arg => undef );
22 55 has 'snapshot' => ( is => 'lazy', init_arg => undef );
23 55 has 'cat' => ( is => 'lazy', init_arg => undef );
24 55 has 'ccr' => ( is => 'lazy', init_arg => undef );
25 55 has 'ilm' => ( is => 'lazy', init_arg => undef );
26 55 has 'tasks' => ( is => 'lazy', init_arg => undef );
27 55 has 'xpack' => ( is => 'lazy', init_arg => undef );
28 55 has 'data_frame' => ( is => 'lazy', init_arg => undef );
29 55 has 'graph' => ( is => 'lazy', init_arg => undef );
30 55 has 'license' => ( is => 'lazy', init_arg => undef );
31 55 has 'migration' => ( is => 'lazy', init_arg => undef );
32 55 has 'ml' => ( is => 'lazy', init_arg => undef );
33 55 has 'monitoring' => ( is => 'lazy', init_arg => undef );
34 55 has 'rollup' => ( is => 'lazy', init_arg => undef );
35 55 has 'security' => ( is => 'lazy', init_arg => undef );
36 55 has 'sql' => ( is => 'lazy', init_arg => undef );
37 55 has 'ssl' => ( is => 'lazy', init_arg => undef );
38 55 has 'watcher' => ( is => 'lazy', init_arg => undef );
39 55 has 'bulk_helper_class' => ( is => 'rw' );
40 55 has 'scroll_helper_class' => ( is => 'rw' );
41 55 has '_bulk_class' => ( is => 'lazy' );
42 55 has '_scroll_class' => ( is => 'lazy' );
43  
44 #===================================
45 sub _build__bulk_class {
46 #===================================
47 0 ▶ my $self = shift;
Subroutine _build__bulk_class: not called CC=2 SCAR=17.9
48 0 ▶ my $bulk_class = $self->bulk_helper_class
Condition0%0/2
$self->bulk_helper_class || 'Client::' . $self->api_version . '::Bulk'
l!l
00
MC/DC0%0/1
$self->bulk_helper_class || 'Client::' . $self->api_version . '::Bulk'
$self->bulk_helper_class
Truth table0%0/2
A
A= $self->bulk_helper_class
Aresult
11
00
49 || 'Client::' . $self->api_version . '::Bulk';
50 0 $self->_build_helper( 'bulk', $bulk_class );
51 }
52  
53 #===================================
54 sub _build__scroll_class {
55 #===================================
56 0 ▶ my $self = shift;
Subroutine _build__scroll_class: not called CC=2 SCAR=17.9
57 0 ▶ my $scroll_class = $self->scroll_helper_class
Condition0%0/2
$self->scroll_helper_class || 'Client::' . $self->api_version . '::Scroll'
l!l
00
MC/DC0%0/1
$self->scroll_helper_class || 'Client::' . $self->api_version . '::Scroll'
$self->scroll_helper_class
Truth table0%0/2
A
A= $self->scroll_helper_class
Aresult
11
00
58 || 'Client::' . $self->api_version . '::Scroll';
59 0 $self->_build_helper( 'scroll', $scroll_class );
60 }
61  
62 #===================================
63 sub bulk_helper {
64 #===================================
65 0 ▶ my ( $self, $params ) = parse_params(@_);
Subroutine bulk_helper: not called CC=2 SCAR=17.9
Pod documented
66 0 ▶ $params->{es} ||= $self;
Condition0%0/3
$params->{"es"} ||= $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->{"es"} ||= $self
$params->{"es"} $self
Truth table0%0/3
A ||= B
A= $params->{"es"}B= $self
ABresult
1X1
011
000
67 0 $self->_bulk_class->new($params);
68 }
69  
70 #===================================
71 sub scroll_helper {
72 #===================================
73 0 ▶ my ( $self, $params ) = parse_params(@_);
Subroutine scroll_helper: not called CC=2 SCAR=17.9
Pod documented
74 0 ▶ $params->{es} ||= $self;
Condition0%0/3
$params->{"es"} ||= $self
l!l&&r!l&&!r
000
MC/DC0%0/2
$params->{"es"} ||= $self
$params->{"es"} $self
Truth table0%0/3
A ||= B
A= $params->{"es"}B= $self
ABresult
1X1
011
000
75 0 $self->_scroll_class->new($params);
76 }
77  
78 #===================================
79 0 ▶sub _build_cluster { shift->_build_namespace('Cluster') }
Subroutine _build_cluster: not called CC=1 SCAR=6.9
80 0 ▶sub _build_nodes { shift->_build_namespace('Nodes') }
Subroutine _build_nodes: not called CC=1 SCAR=6.9
81 0 ▶sub _build_indices { shift->_build_namespace('Indices') }
Subroutine _build_indices: not called CC=1 SCAR=6.9
82 0 ▶sub _build_ingest { shift->_build_namespace('Ingest') }
Subroutine _build_ingest: not called CC=1 SCAR=6.9
83 0 ▶sub _build_snapshot { shift->_build_namespace('Snapshot') }
Subroutine _build_snapshot: not called CC=1 SCAR=6.9
84 0 ▶sub _build_cat { shift->_build_namespace('Cat') }
Subroutine _build_cat: not called CC=1 SCAR=6.9
85 0 ▶sub _build_ccr { shift->_build_namespace('CCR') }
Subroutine _build_ccr: not called CC=1 SCAR=6.9
86 0 ▶sub _build_ilm { shift->_build_namespace('ILM') }
Subroutine _build_ilm: not called CC=1 SCAR=6.9
87 0 ▶sub _build_tasks { shift->_build_namespace('Tasks') }
Subroutine _build_tasks: not called CC=1 SCAR=6.9
88 0 ▶sub _build_xpack { shift->_build_namespace('XPack') }
Subroutine _build_xpack: not called CC=1 SCAR=6.9
89 0 ▶sub _build_data_frame { shift->_build_namespace('DataFrame') }
Subroutine _build_data_frame: not called CC=1 SCAR=6.9
90 0 ▶sub _build_graph { shift->_build_namespace('Graph') }
Subroutine _build_graph: not called CC=1 SCAR=6.9
91 0 ▶sub _build_license { shift->_build_namespace('License') }
Subroutine _build_license: not called CC=1 SCAR=6.9
92 0 ▶sub _build_migration { shift->_build_namespace('Migration') }
Subroutine _build_migration: not called CC=1 SCAR=6.9
93 0 ▶sub _build_ml { shift->_build_namespace('ML') }
Subroutine _build_ml: not called CC=1 SCAR=6.9
94 0 ▶sub _build_monitoring { shift->_build_namespace('Monitoring') }
Subroutine _build_monitoring: not called CC=1 SCAR=6.9
95 0 ▶sub _build_rollup { shift->_build_namespace('Rollup') }
Subroutine _build_rollup: not called CC=1 SCAR=6.9
96 0 ▶sub _build_security { shift->_build_namespace('Security') }
Subroutine _build_security: not called CC=1 SCAR=6.9
97 0 ▶sub _build_sql { shift->_build_namespace('SQL') }
Subroutine _build_sql: not called CC=1 SCAR=6.9
98 0 ▶sub _build_ssl { shift->_build_namespace('SSL') }
Subroutine _build_ssl: not called CC=1 SCAR=6.9
99 0 ▶sub _build_watcher { shift->_build_namespace('Watcher') }
Subroutine _build_watcher: not called CC=1 SCAR=6.9
100 #===================================
101  
102 55 __PACKAGE__->_install_api('');
103  
104 55 1;
105  
106 =pod
107  
108 =encoding UTF-8
109  
110 =head1 NAME
111  
112 Search::Elasticsearch::Client::7_0::Direct - Thin client with full support for Elasticsearch 7.x APIs
113  
114 =head1 VERSION
115  
116 version 7.30_1
117  
118 =head1 SYNOPSIS
119  
120 Create a client:
121  
122 use Search::Elasticsearch;
123 my $e = Search::Elasticsearch->new(
124 client => '7_0::Direct'
125 );
126  
127 Index a doc:
128  
129 $e->index(
130 index => 'my_index',
131 type => 'blog_post',
132 id => 123,
133 body => {
134 title => "Elasticsearch clients",
135 content => "Interesting content...",
136 date => "2013-09-23"
137 }
138 );
139  
140 Get a doc:
141  
142 $e->get(
143 index => 'my_index',
144 type => 'my_type',
145 id => 123
146 );
147  
148 Search for docs:
149  
150 $results = $e->search(
151 index => 'my_index',
152 body => {
153 query => {
154 match => {
155 title => "elasticsearch"
156 }
157 }
158 }
159 );
160  
161 Index-level requests:
162  
163 $e->indices->create( index => 'my_index' );
164 $e->indices->delete( index => 'my_index' )
165  
166 Ingest pipeline requests:
167  
168 $e->ingest->get_pipeline( id => 'apache-logs' );
169  
170 Cluster-level requests:
171  
172 $health = $e->cluster->health;
173  
174 Node-level requests:
175  
176 $info = $e->nodes->info;
177 $stats = $e->nodes->stats;
178  
179 Snapshot and restore:
180  
181 $e->snapshot->create_repository(
182 repository => 'my_backups',
183 type => 'fs',
184 settings => {
185 location => '/mnt/backups'
186 }
187 );
188  
189 $e->snapshot->create(
190 repository => 'my_backups',
191 snapshot => 'backup_2014'
192 );
193  
194 Task management:
195  
196 $e->tasks->list;
197  
198 `cat` debugging:
199  
200 say $e->cat->allocation;
201 say $e->cat->health;
202  
203 Cross-cluster replication requests:
204  
205 say $e->ccr->follow;
206  
207 Index lifecycle management requests:
208  
209 say $e->ilm->put_lifecycle;
210  
211 =head1 DESCRIPTION
212  
213 The L<Search::Elasticsearch::Client::7_0::Direct> class provides the
214 Elasticsearch 7.x compatible client returned by:
215  
216 $e = Search::Elasticsearch->new(
217 client => "7_0::Direct" # default
218 );
219  
220 It is intended to be as close as possible to the native REST API that
221 Elasticsearch uses, so that it is easy to translate the
222 L<Elasticsearch reference documentation|http://www.elasticsearch/guide>
223 for an API to the equivalent in this client.
224  
225 This class provides the methods for L<document CRUD|/DOCUMENT CRUD METHODS>,
226 L<bulk document CRUD|/BULK DOCUMENT CRUD METHODS> and L<search|/SEARCH METHODS>.
227 It also provides access to clients for managing L<indices|/indices()>
228 and the L<cluster|/cluster()>.
229  
230 =head1 PREVIOUS VERSIONS OF ELASTICSEARCH
231  
232 This version of the client supports the Elasticsearch 7.0 branch,
233 which is not backwards compatible with earlier branches.
234  
235 If you need to talk to a version of Elasticsearch before 7.0.0, please
236 install one of the following modules:
237  
238 =over
239  
240 =item *
241  
242 L<Search::Elasticsearch::Client::6_0>
243  
244 =item *
245  
246 L<Search::Elasticsearch::Client::5_0>
247  
248 =item *
249  
250 L<Search::Elasticsearch::Client::2_0>
251  
252 =item *
253  
254 L<Search::Elasticsearch::Client::1_0>
255  
256 =item *
257  
258 L<Search::Elasticsearch::Client::0_90>
259  
260 =back
261  
262 =head1 CONVENTIONS
263  
264 =head2 Parameter passing
265  
266 Parameters can be passed to any request method as a list or as a hash
267 reference. The following two statements are equivalent:
268  
269 $e->search( size => 10 );
270 $e->search({size => 10});
271  
272 =head2 Path parameters
273  
274 Any values that should be included in the URL path, eg C</{index}/{type}>
275 should be passed as top level parameters:
276  
277 $e->search( index => 'my_index', type => 'my_type' );
278  
279 Alternatively, you can specify a C<path> parameter directly:
280  
281 $e->search( path => '/my_index/my_type' );
282  
283 =head2 Query-string parameters
284  
285 Any values that should be included in the query string should be passed
286 as top level parameters:
287  
288 $e->search( size => 10 );
289  
290 If you pass in a C<\%params> hash, then it will be included in the
291 query string parameters without any error checking. The following:
292  
293 $e->search( size => 10, params => { from => 6, size => 6 })
294  
295 would result in this query string:
296  
297 ?from=6&size=10
298  
299 =head2 Body parameter
300  
301 The request body should be passed in the C<body> key:
302  
303 $e->search(
304 body => {
305 query => {...}
306 }
307 );
308  
309 The body can also be a UTF8-decoded string, which will be converted into
310 UTF-8 bytes and passed as is:
311  
312 $e->indices->analyze( body => "The quick brown fox");
313  
314 =head2 Boolean parameters
315  
316 Elasticsearch 7.0.0 and above no longer accepts truthy and falsey values for booleans. Instead,
317 it will accept only a JSON C<true> or C<false>, or the string equivalents C<"true"> or C<"false">.
318  
319 In the Perl client, you can use the following values:
320  
321 =over
322  
323 =item * True: C<true>, C<\1>, or a L<JSON::PP::Boolean> object.
324  
325 =item * False: C<false>, C<\0>, or a L<JSON::PP::Boolean> object.
326  
327 =back
328  
329 =head2 Filter path parameter
330  
331 Any API which returns a JSON body accepts a C<filter_path> parameter
332 which will filter the JSON down to only the specified paths. For instance,
333 if you are running a search request and only want the C<total> hits and
334 the C<_source> field for each hit (without the C<_id>, C<_index> etc),
335 you can do:
336  
337 $e->search(
338 query => {...},
339 filter_paths => [ 'hits.total', 'hits.hits._source' ]
340 );
341  
342 =head2 Ignore parameter
343  
344 Normally, any HTTP status code outside the 200-299 range will result in
345 an error being thrown. To suppress these errors, you can specify which
346 status codes to ignore in the C<ignore> parameter.
347  
348 $e->indices->delete(
349 index => 'my_index',
350 ignore => 404
351 );
352  
353 This is most useful for
354 L<Missing|Search::Elasticsearch::Error/Search::Elasticsearch::Error::Missing> errors, which
355 are triggered by a C<404> status code when some requested resource does
356 not exist.
357  
358 Multiple error codes can be specified with an array:
359  
360 $e->indices->delete(
361 index => 'my_index',
362 ignore => [404,409]
363 );
364  
365 =head1 CONFIGURATION
366  
367 =head2 C<bulk_helper_class>
368  
369 The class to use for the L</bulk_helper()> method. Defaults to
370 L<Search::Elasticsearch::Client::7_0::Bulk>.
371  
372 =head2 C<scroll_helper_class>
373  
374 The class to use for the L</scroll_helper()> method. Defaults to
375 L<Search::Elasticsearch::Client::7_0::Scroll>.
376  
377 =head1 GENERAL METHODS
378  
379 =head2 C<info()>
380  
381 $info = $e->info
382  
383 Returns information about the version of Elasticsearch that the responding node
384 is running.
385  
386 =head2 C<ping()>
387  
388 $e->ping
389  
390 Pings a node in the cluster and returns C<1> if it receives a C<200>
391 response, otherwise it throws an error.
392  
393 =head2 C<indices()>
394  
395 $indices_client = $e->indices;
396  
397 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Indices> object which can be used
398 for managing indices, eg creating, deleting indices, managing mapping,
399 index settings etc.
400  
401 =head2 C<ingest()>
402  
403 $ingest_client = $e->ingest;
404  
405 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Ingest> object which can be used
406 for managing ingest pipelines.
407  
408 =head2 C<cluster()>
409  
410 $cluster_client = $e->cluster;
411  
412 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Cluster> object which can be used
413 for managing the cluster, eg cluster-wide settings and cluster health.
414  
415 =head2 C<nodes()>
416  
417 $node_client = $e->nodes;
418  
419 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Nodes> object which can be used
420 to retrieve node info and stats.
421  
422 =head2 C<snapshot()>
423  
424 $snapshot_client = $e->snapshot;
425  
426 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Snapshot> object which
427 is used for managing backup repositories and creating and restoring
428 snapshots.
429  
430 =head2 C<tasks()>
431  
432 $tasks_client = $e->tasks;
433  
434 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Tasks> object which
435 is used for accessing the task management API.
436  
437 =head2 C<cat()>
438  
439 $cat_client = $e->cat;
440  
441 Returns a L<Search::Elasticsearch::Client::7_0::Direct::Cat> object which can be used
442 to retrieve simple to read text info for debugging and monitoring an
443 Elasticsearch cluster.
444  
445 =head2 C<ccr()>
446  
447 $ccr_client = $e->ccr;
448  
449 Returns a L<Search::Elasticsearch::Client::7_0::Direct::CCR> object which can be used
450 to handle cross-cluster replication requests.
451  
452 =head2 C<ilm()>
453  
454 $ilm_client = $e->ilm;
455  
456 Returns a L<Search::Elasticsearch::Client::7_0::Direct::ILM> object which can be used
457 to handle index lifecycle management requests.
458  
459 =head1 DOCUMENT CRUD METHODS
460  
461 These methods allow you to perform create, index, update and delete requests
462 for single documents:
463  
464 =head2 C<index()>
465  
466 $response = $e->index(
467 index => 'index_name', # required
468 type => 'type_name', # required
469 id => 'doc_id', # optional, otherwise auto-generated
470  
471 body => { document } # required
472 );
473  
474 The C<index()> method is used to index a new document or to reindex
475 an existing document.
476  
477 Query string parameters:
478 C<error_trace>,
479 C<human>,
480 C<if_primary_term>,
481 C<if_seq_no>,
482 C<op_type>,
483 C<parent>,
484 C<pipeline>,
485 C<refresh>,
486 C<routing>,
487 C<timeout>,
488 C<version>,
489 C<version_type>,
490 C<wait_for_active_shards>
491  
492 See the L<index docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>
493 for more information.
494  
495 =head2 C<create()>
496  
497 $response = $e->create(
498 index => 'index_name', # required
499 type => 'type_name', # required
500 id => 'doc_id', # required
501  
502 body => { document } # required
503 );
504  
505 The C<create()> method works exactly like the L</index()> method, except
506 that it will throw a C<Conflict> error if a document with the same
507 C<index>, C<type> and C<id> already exists.
508  
509 Query string parameters:
510 C<consistency>,
511 C<error_trace>,
512 C<human>,
513 C<op_type>,
514 C<parent>,
515 C<refresh>,
516 C<routing>,
517 C<timeout>,
518 C<version>,
519 C<version_type>
520  
521 See the L<create docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-create.html>
522 for more information.
523  
524 =head2 C<get()>
525  
526 $response = $e->get(
527 index => 'index_name', # required
528 type => 'type_name', # required
529 id => 'doc_id', # required
530 );
531  
532 The C<get()> method will retrieve the document with the specified
533 C<index>, C<type> and C<id>, or will throw a C<Missing> error.
534  
535 Query string parameters:
536 C<_source>,
537 C<_source_excludes>,
538 C<_source_includes>,
539 C<error_trace>,
540 C<human>,
541 C<parent>,
542 C<preference>,
543 C<realtime>,
544 C<refresh>,
545 C<routing>,
546 C<stored_fields>,
547 C<version>,
548 C<version_type>
549  
550 See the L<get docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>
551 for more information.
552  
553 =head2 C<get_source()>
554  
555 $response = $e->get_source(
556 index => 'index_name', # required
557 type => 'type_name', # required
558 id => 'doc_id', # required
559 );
560  
561 The C<get_source()> method works just like the L</get()> method except that
562 it returns just the C<_source> field (the value of the C<body> parameter
563 in the L</index()> method) instead of returning the C<_source> field
564 plus the document metadata, ie the C<_index>, C<_type> etc.
565  
566 Query string parameters:
567 C<_source>,
568 C<_source_excludes>,
569 C<_source_includes>,
570 C<error_trace>,
571 C<human>,
572 C<parent>,
573 C<preference>,
574 C<realtime>,
575 C<refresh>,
576 C<routing>,
577 C<version>,
578 C<version_type>
579  
580 See the L<get_source docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>
581 for more information.
582  
583 =head2 C<exists()>
584  
585 $response = $e->exists(
586 index => 'index_name', # required
587 type => 'type_name', # required
588 id => 'doc_id', # required
589 );
590  
591 The C<exists()> method returns C<1> if a document with the specified
592 C<index>, C<type> and C<id> exists, or an empty string if it doesn't.
593  
594 Query string parameters:
595 C<_source>,
596 C<_source_excludes>,
597 C<_source_includes>,
598 C<error_trace>,
599 C<human>,
600 C<parent>,
601 C<preference>,
602 C<realtime>,
603 C<refresh>,
604 C<routing>,
605 C<version>,
606 C<version_type>
607  
608 See the L<exists docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>
609 for more information.
610  
611 =head2 C<delete()>
612  
613 $response = $e->delete(
614 index => 'index_name', # required
615 type => 'type_name', # required
616 id => 'doc_id', # required
617 );
618  
619 The C<delete()> method will delete the document with the specified
620 C<index>, C<type> and C<id>, or will throw a C<Missing> error.
621  
622 Query string parameters:
623 C<error_trace>,
624 C<human>,
625 C<if_primary_term>,
626 C<if_seq_no>,
627 C<parent>,
628 C<refresh>,
629 C<routing>,
630 C<timeout>,
631 C<version>,
632 C<version_type>,
633 C<wait_for_active_shards>
634  
635 See the L<delete docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html>
636 for more information.
637  
638 =head2 C<update()>
639  
640 $response = $e->update(
641 index => 'index_name', # required
642 type => 'type_name', # required
643 id => 'doc_id', # required
644  
645 body => { update } # required
646 );
647  
648 The C<update()> method updates a document with the corresponding
649 C<index>, C<type> and C<id> if it exists. Updates can be performed either by:
650  
651 =over
652  
653 =item * providing a partial document to be merged in to the existing document:
654  
655 $response = $e->update(
656 ...,
657 body => {
658 doc => { new_field => 'new_value'},
659 }
660 );
661  
662 =item * with an inline script:
663  
664 $response = $e->update(
665 ...,
666 body => {
667 script => {
668 source => "ctx._source.counter += incr",
669 params => { incr => 6 }
670 }
671 }
672 );
673  
674 =item * with an indexed script:
675  
676 $response = $e->update(
677 ...,
678 body => {
679 script => {
680 id => $id,
681 lang => 'painless',
682 params => { incr => 6 }
683 }
684 }
685 );
686  
687 See L<indexed scripts|https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts>
688 for more information.
689  
690 =item * with a script stored as a file:
691  
692 $response = $e->update(
693 ...,
694 body => {
695 script => {
696 file => 'counter',
697 lang => 'painless',
698 params => { incr => 6 }
699 }
700 }
701 );
702  
703 See L<scripting docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>
704 for more information.
705  
706 =back
707  
708 Query string parameters:
709 C<_source>,
710 C<_source_excludes>,
711 C<_source_includes>,
712 C<error_trace>,
713 C<fields>,
714 C<human>,
715 C<if_primary_term>,
716 C<if_seq_no>,
717 C<lang>,
718 C<parent>,
719 C<refresh>,
720 C<retry_on_conflict>,
721 C<routing>,
722 C<timeout>,
723 C<version>,
724 C<version_type>,
725 C<wait_for_active_shards>
726  
727 See the L<update docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>
728 for more information.
729  
730 =head2 C<termvectors()>
731  
732 $results = $e->termvectors(
733 index => $index, # required
734 type => $type, # required
735  
736 id => $id, # optional
737 body => {...} # optional
738 )
739  
740 The C<termvectors()> method retrieves term and field statistics, positions,
741 offsets and payloads for the specified document, assuming that termvectors
742 have been enabled.
743  
744 Query string parameters:
745 C<error_trace>,
746 C<field_statistics>,
747 C<fields>,
748 C<human>,
749 C<offsets>,
750 C<parent>,
751 C<payloads>,
752 C<positions>,
753 C<preference>,
754 C<realtime>,
755 C<routing>,
756 C<term_statistics>,
757 C<version>,
758 C<version_type>
759  
760 See the L<termvector docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html>
761 for more information.
762  
763 =head1 BULK DOCUMENT CRUD METHODS
764  
765 The bulk document CRUD methods are used for running multiple CRUD actions
766 within a single request. By reducing the number of network requests
767 that need to be made, bulk requests greatly improve performance.
768  
769 =head2 C<bulk()>
770  
771 $response = $e->bulk(
772 index => 'index_name', # required if type specified
773 type => 'type_name', # optional
774  
775 body => [ actions ] # required
776 );
777  
778 See L<Search::Elasticsearch::Client::7_0::Bulk> and L</bulk_helper()> for a helper module that makes
779 bulk indexing simpler to use.
780  
781 The C<bulk()> method can perform multiple L</index()>, L</create()>,
782 L</delete()> or L</update()> actions with a single request. The C<body>
783 parameter expects an array containing the list of actions to perform.
784  
785 An I<action> consists of an initial metadata hash ref containing the action
786 type, plus the associated metadata, eg :
787  
788 { delete => { _index => 'index', _type => 'type', _id => 123 }}
789  
790 The C<index> and C<create> actions then expect a hashref containing
791 the document itself:
792  
793 { create => { _index => 'index', _type => 'type', _id => 123 }},
794 { title => "A newly created document" }
795  
796 And the C<update> action expects a hashref containing the update commands,
797 eg:
798  
799 { update => { _index => 'index', _type => 'type', _id => 123 }},
800 { script => "ctx._source.counter+=1" }
801  
802 Each action can include the same parameters that you would pass to
803 the equivalent L</index()>, L</create()>, L</delete()> or L</update()>
804 request, except that C<_index>, C<_type> and C<_id> must be specified with
805 the preceding underscore. All other parameters can be specified with or
806 without the underscore.
807  
808 For instance:
809  
810 $response = $e->bulk(
811 index => 'index_name', # default index name
812 type => 'type_name', # default type name
813 body => [
814  
815 # create action
816 { create => {
817 _index => 'not_the_default_index',
818 _type => 'not_the_default_type',
819 _id => 123
820 }},
821 { title => 'Foo' },
822  
823 # index action
824 { index => { _id => 124 }},
825 { title => 'Foo' },
826  
827 # delete action
828 { delete => { _id => 126 }},
829  
830 # update action
831 { update => { _id => 126 }},
832 { script => "ctx._source.counter+1" }
833 ]
834 );
835  
836 Each action is performed separately. One failed action will not
837 cause the others to fail as well.
838  
839 Query string parameters:
840 C<_source>,
841 C<_source_excludes>,
842 C<_source_includes>,
843 C<error_trace>,
844 C<fields>,
845 C<human>,
846 C<pipeline>,
847 C<refresh>,
848 C<routing>,
849 C<timeout>,
850 C<wait_for_active_shards>
851  
852 See the L<bulk docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html>
853 for more information.
854  
855 =head2 C<bulk_helper()>
856  
857 $bulk_helper = $e->bulk_helper( @args );
858  
859 Returns a new instance of the class specified in the L</bulk_helper_class>,
860 which defaults to L<Search::Elasticsearch::Client::7_0::Bulk>.
861  
862 =head2 C<mget()>
863  
864 $results = $e->mget(
865 index => 'default_index', # optional, required when type specified
866 type => 'default_type', # optional
867  
868 body => { docs or ids } # required
869 );
870  
871 The C<mget()> method will retrieve multiple documents with a single request.
872 The C<body> consists of an array of documents to retrieve:
873  
874 $results = $e->mget(
875 index => 'default_index',
876 type => 'default_type',
877 body => {
878 docs => [
879 { _id => 1},
880 { _id => 2, _type => 'not_the_default_type' }
881 ]
882 }
883 );
884  
885 You can also pass any of the other parameters that the L</get()> request
886 accepts.
887  
888 If you have specified an C<index> and C<type>, you can just include the
889 C<ids> of the documents to retrieve:
890  
891 $results = $e->mget(
892 index => 'default_index',
893 type => 'default_type',
894 body => {
895 ids => [ 1, 2, 3]
896 }
897 );
898  
899 Query string parameters:
900 C<_source>,
901 C<_source_excludes>,
902 C<_source_includes>,
903 C<error_trace>,
904 C<human>,
905 C<preference>,
906 C<realtime>,
907 C<refresh>,
908 C<routing>,
909 C<stored_fields>
910  
911 See the L<mget docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>
912 for more information.
913  
914 =head2 C<mtermvectors()>
915  
916 $results = $e->mtermvectors(
917 index => $index, # required if type specified
918 type => $type, # optional
919  
920 body => { } # optional
921 )
922  
923 Runs multiple L</termvector()> requests in a single request, eg:
924  
925 $results = $e->mtermvectors(
926 index => 'test',
927 body => {
928 docs => [
929 { _type => 'test', _id => 1, fields => ['text'] },
930 { _type => 'test', _id => 2, payloads => 1 },
931 ]
932 }
933 );
934  
935 Query string parameters:
936 C<error_trace>,
937 C<field_statistics>,
938 C<fields>,
939 C<human>,
940 C<ids>,
941 C<offsets>,
942 C<parent>,
943 C<payloads>,
944 C<positions>,
945 C<preference>,
946 C<realtime>,
947 C<routing>,
948 C<term_statistics>,
949 C<version>,
950 C<version_type>
951  
952 See the L<mtermvectors docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html>
953 for more information.
954  
955 =head1 SEARCH METHODS
956  
957 The search methods are used for querying documents in one, more or all indices
958 and of one, more or all types:
959  
960 =head2 C<search()>
961  
962 $results = $e->search(
963 index => 'index' | \@indices, # optional
964 type => 'type' | \@types, # optional
965  
966 body => { search params } # optional
967 );
968  
969 The C<search()> method searches for matching documents in one or more
970 indices. It is just as easy to search a single index as it is to search
971 all the indices in your cluster. It can also return
972 L<aggregations|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html>
973 L<highlighted snippets|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-highlighting.html>
974 and L<did-you-mean|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html>
975 or L<search-as-you-type|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html>
976 suggestions.
977  
978 The I<lite> L<version of search|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html>
979 allows you to specify a query string in the C<q> parameter, using the
980 Lucene query string syntax:
981  
982 $results = $e->search( q => 'title:(elasticsearch clients)');
983  
984 However, the preferred way to search is by using the
985 L<Query DSL|http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html>
986 to create a query, and passing that C<query> in the
987 L<request body|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html>:
988  
989 $results = $e->search(
990 body => {
991 query => {
992 match => { title => 'Elasticsearch clients'}
993 }
994 }
995 );
996  
997 Query string parameters:
998 C<_source>,
999 C<_source_excludes>,
1000 C<_source_includes>,
1001 C<allow_no_indices>,
1002 C<allow_partial_search_results>,
1003 C<analyze_wildcard>,
1004 C<analyzer>,
1005 C<batched_reduce_size>,
1006 C<default_operator>,
1007 C<df>,
1008 C<docvalue_fields>,
1009 C<error_trace>,
1010 C<expand_wildcards>,
1011 C<explain>,
1012 C<from>,
1013 C<human>,
1014 C<ignore_throttled>,
1015 C<ignore_unavailable>,
1016 C<lenient>,
1017 C<max_concurrent_shard_requests>,
1018 C<pre_filter_shard_size>,
1019 C<preference>,
1020 C<q>,
1021 C<request_cache>,
1022 C<rest_total_hits_as_int>,
1023 C<routing>,
1024 C<scroll>,
1025 C<search_type>,
1026 C<seq_no_primary_term>,
1027 C<size>,
1028 C<sort>,
1029 C<stats>,
1030 C<stored_fields>,
1031 C<suggest_field>,
1032 C<suggest_mode>,
1033 C<suggest_size>,
1034 C<suggest_text>,
1035 C<terminate_after>,
1036 C<timeout>,
1037 C<track_scores>,
1038 C<track_total_hits>,
1039 C<typed_keys>,
1040 C<version>
1041  
1042 See the L<search reference|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html>
1043 for more information.
1044  
1045 Also see L<Search::Elasticsearch::Transport/send_get_body_as>.
1046  
1047 =head2 C<count()>
1048  
1049 $results = $e->count(
1050 index => 'index' | \@indices, # optional
1051 type => 'type' | \@types, # optional
1052  
1053 body => { query } # optional
1054 )
1055  
1056 The C<count()> method returns the total count of all documents matching the
1057 query:
1058  
1059 $results = $e->count(
1060 body => {
1061 query => {
1062 match => { title => 'Elasticsearch clients' }
1063 }
1064 }
1065 );
1066  
1067 Query string parameters:
1068 C<allow_no_indices>,
1069 C<analyze_wildcard>,
1070 C<analyzer>,
1071 C<default_operator>,
1072 C<df>,
1073 C<error_trace>,
1074 C<expand_wildcards>,
1075 C<human>,
1076 C<ignore_throttled>,
1077 C<ignore_unavailable>,
1078 C<lenient>,
1079 C<lowercase_expanded_terms>
1080 C<min_score>,
1081 C<preference>,
1082 C<q>,
1083 C<routing>,
1084 C<terminate_after>
1085  
1086 See the L<count docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html>
1087 for more information.
1088  
1089 =head2 C<search_template()>
1090  
1091 $results = $e->search_template(
1092 index => 'index' | \@indices, # optional
1093 type => 'type' | \@types, # optional
1094  
1095 body => { search params } # required
1096 );
1097  
1098 Perform a search by specifying a template (either predefined or defined
1099 within the C<body>) and parameters to use with the template, eg:
1100  
1101 $results = $e->search_template(
1102 body => {
1103 source => {
1104 query => {
1105 match => {
1106 "{{my_field}}" => "{{my_value}}"
1107 }
1108 },
1109 size => "{{my_size}}"
1110 },
1111 params => {
1112 my_field => 'foo',
1113 my_value => 'bar',
1114 my_size => 6
1115 }
1116 }
1117 );
1118  
1119 See the L<search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>
1120 for more information.
1121  
1122 Query string parameters:
1123 C<allow_no_indices>,
1124 C<error_trace>,
1125 C<expand_wildcards>,
1126 C<explain>,
1127 C<human>,
1128 C<ignore_throttled>,
1129 C<ignore_unavailable>,
1130 C<preference>,
1131 C<profile>,
1132 C<rest_total_hits_as_int>,
1133 C<scroll>,
1134 C<search_type>,
1135 C<typed_keys>
1136  
1137 =head2 C<render_search_template()>
1138  
1139 $response = $e->render_search_template(
1140 id => 'id', # optional
1141 body => { template } # optional
1142 );
1143  
1144 Renders the template, filling in the passed-in parameters and returns the resulting JSON, eg:
1145  
1146 $results = $e->render_search_template(
1147 body => {
1148 source => {
1149 query => {
1150 match => {
1151 "{{my_field}}" => "{{my_value}}"
1152 }
1153 },
1154 size => "{{my_size}}"
1155 },
1156 params => {
1157 my_field => 'foo',
1158 my_value => 'bar',
1159 my_size => 6
1160 }
1161 }
1162 );
1163  
1164 See the L<search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>
1165 for more information.
1166  
1167 =head2 C<scroll()>
1168  
1169 $results = $e->scroll(
1170 scroll => '1m',
1171 body => {
1172 scroll_id => $id
1173 }
1174 );
1175  
1176 When a L</search()> has been performed with the
1177 C<scroll> parameter, the C<scroll()>
1178 method allows you to keep pulling more results until the results
1179 are exhausted.
1180  
1181 See L</scroll_helper()> and L<Search::Elasticsearch::Client::7_0::Scroll> for a helper utility
1182 which makes managing scroll requests much easier.
1183  
1184 Query string parameters:
1185 C<error_trace>,
1186 C<human>,
1187 C<rest_total_hits_as_int>,
1188 C<scroll>,
1189 C<scroll_id>
1190  
1191 See the L<scroll docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>
1192 and the L<search_type docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html/search-request-search-type.html>
1193 for more information.
1194  
1195 =head2 C<clear_scroll()>
1196  
1197 $response = $e->clear_scroll(
1198 body => {
1199 scroll_id => $id | \@ids # required
1200 }
1201 );
1202  
1203 The C<clear_scroll()> method can clear unfinished scroll requests, freeing
1204 up resources on the server.
1205  
1206 =head2 C<scroll_helper()>
1207  
1208 $scroll_helper = $e->scroll_helper( @args );
1209  
1210 Returns a new instance of the class specified in the L</scroll_helper_class>,
1211 which defaults to L<Search::Elasticsearch::Client::7_0::Scroll>.
1212  
1213 =head2 C<msearch()>
1214  
1215 $results = $e->msearch(
1216 index => 'default_index' | \@indices, # optional
1217 type => 'default_type' | \@types, # optional
1218  
1219 body => [ searches ] # required
1220 );
1221  
1222 The C<msearch()> method allows you to perform multiple searches in a single
1223 request. Similar to the L</bulk()> request, each search request in the
1224 C<body> consists of two hashes: the metadata hash then the search request
1225 hash (the same data that you'd specify in the C<body> of a L</search()>
1226 request). For instance:
1227  
1228 $results = $e->msearch(
1229 index => 'default_index',
1230 type => ['default_type_1', 'default_type_2'],
1231 body => [
1232 # uses defaults
1233 {},
1234 { query => { match_all => {} }},
1235  
1236 # uses a custom index
1237 { index => 'not_the_default_index' },
1238 { query => { match_all => {} }}
1239 ]
1240 );
1241  
1242 Query string parameters:
1243 C<error_trace>,
1244 C<human>,
1245 C<max_concurrent_searches>,
1246 C<max__concurrent_shard_requests>,
1247 C<pre_filter_shard_size>,
1248 C<rest_total_hits_as_int>,
1249 C<search_type>,
1250 C<typed_keys>
1251  
1252 See the L<msearch docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>
1253 for more information.
1254  
1255 =head2 C<msearch_template()>
1256  
1257 $results = $e->msearch_template(
1258 index => 'default_index' | \@indices, # optional
1259 type => 'default_type' | \@types, # optional
1260  
1261 body => [ search_templates ] # required
1262 );
1263  
1264 The C<msearch_template()> method allows you to perform multiple searches in a single
1265 request using search templates. Similar to the L</bulk()> request, each search
1266 request in the C<body> consists of two hashes: the metadata hash then the search request
1267 hash (the same data that you'd specify in the C<body> of a L</search()>
1268 request). For instance:
1269  
1270 $results = $e->msearch(
1271 index => 'default_index',
1272 type => ['default_type_1', 'default_type_2'],
1273 body => [
1274 # uses defaults
1275 {},
1276 { source => { query => { match => { user => "{{user}}" }}} params => { user => 'joe' }},
1277  
1278 # uses a custom index
1279 { index => 'not_the_default_index' },
1280 { source => { query => { match => { user => "{{user}}" }}} params => { user => 'joe' }},
1281 ]
1282 );
1283  
1284 Query string parameters:
1285 C<error_trace>,
1286 C<human>,
1287 C<max_concurrent_searches>,
1288 C<rest_total_hits_as_int>,
1289 C<search_type>,
1290 C<typed_keys>
1291  
1292 See the L<msearch-template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>
1293 for more information.
1294  
1295 =head2 C<explain()>
1296  
1297 $response = $e->explain(
1298 index => 'my_index', # required
1299 type => 'my_type', # required
1300 id => 123, # required
1301  
1302 body => { search } # required
1303 );
1304  
1305 The C<explain()> method explains why the specified document did or
1306 did not match a query, and how the relevance score was calculated.
1307 For instance:
1308  
1309 $response = $e->explain(
1310 index => 'my_index',
1311 type => 'my_type',
1312 id => 123,
1313 body => {
1314 query => {
1315 match => { title => 'Elasticsearch clients' }
1316 }
1317 }
1318 );
1319  
1320 Query string parameters:
1321 C<_source>,
1322 C<_source_excludes>,
1323 C<_source_includes>,
1324 C<analyze_wildcard>,
1325 C<analyzer>,
1326 C<default_operator>,
1327 C<df>,
1328 C<error_trace>,
1329 C<human>,
1330 C<lenient>,
1331 C<parent>,
1332 C<preference>,
1333 C<q>,
1334 C<routing>,
1335 C<stored_fields>
1336  
1337 See the L<explain docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html>
1338 for more information.
1339  
1340 =head2 C<field_caps()>
1341  
1342 $response = $e->field_caps(
1343 index => 'index' | \@indices, # optional
1344 body => { filters } # optional
1345 );
1346  
1347 The C<field-caps> API returns field types and abilities, merged across indices.
1348  
1349 Query string parameters:
1350 C<allow_no_indices>,
1351 C<error_trace>,
1352 C<expand_wildcards>,
1353 C<fields>,
1354 C<human>,
1355 C<ignore_unavailable>
1356  
1357 See the L<field-caps docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html>
1358 for more information.
1359  
1360 =head2 C<search_shards()>
1361  
1362 $response = $e->search_shards(
1363 index => 'index' | \@indices, # optional
1364 )
1365  
1366 The C<search_shards()> method returns information about which shards on
1367 which nodes will execute a search request.
1368  
1369 Query string parameters:
1370 C<allow_no_indices>,
1371 C<error_trace>,
1372 C<expand_wildcards>,
1373 C<human>,
1374 C<ignore_unavailable>,
1375 C<local>,
1376 C<preference>,
1377 C<routing>
1378  
1379 See the L<search-shards docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html>
1380 for more information.
1381  
1382 =head2 C<rank_eval()>
1383  
1384 $result = $e->rank_eval(
1385 index => 'index' | \@indices, # optional
1386 body => {...} # required
1387 );
1388  
1389 The ranking evaluation API provides a way to execute test cases to determine whether search results
1390 are improving or worsening.
1391  
1392 Query string parameters:
1393 C<allow_no_indices>,
1394 C<error_trace>,
1395 C<expand_wildcards>,
1396 C<filter_path>,
1397 C<human>,
1398 C<ignore_unavailable>
1399  
1400 See the L<rank-eval docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html>
1401 for more information.
1402  
1403 =head1 CRUD-BY-QUERY METHODS
1404  
1405 =head2 C<delete_by_query()>
1406  
1407 $response = $e->delete_by_query(
1408 index => 'index' | \@indices, # optional
1409 type => 'type' | \@types, # optional,
1410 body => { delete-by-query } # required
1411 );
1412  
1413 The C<delete_by_query()> method deletes all documents which match the specified query.
1414  
1415 Query string parameters:
1416 C<_source>,
1417 C<_source_excludes>,
1418 C<_source_includes>,
1419 C<allow_no_indices>,
1420 C<analyze_wildcard>,
1421 C<analyzer>,
1422 C<conflicts>,
1423 C<default_operator>,
1424 C<df>,
1425 C<error_trace>,
1426 C<expand_wildcards>,
1427 C<from>,
1428 C<human>,
1429 C<ignore_unavailable>,
1430 C<lenient>,
1431 C<preference>,
1432 C<q>,
1433 C<refresh>,
1434 C<request_cache>,
1435 C<requests_per_second>,
1436 C<routing>,
1437 C<scroll>,
1438 C<scroll_size>,
1439 C<search_timeout>,
1440 C<search_type>,
1441 C<size>,
1442 C<slices>,
1443 C<sort>,
1444 C<stats>,
1445 C<terminate_after>,
1446 C<version>,
1447 C<timeout>,
1448 C<wait_for_active_shards>,
1449 C<wait_for_completion>
1450  
1451 See the L<delete-by-query docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html>
1452 for more information.
1453  
1454 =head2 C<delete_by_query_rethrottle()>
1455  
1456 $response = $e->delete_by_query_rethrottle(
1457 task_id => 'id' # required
1458 requests_per_second => num
1459 );
1460  
1461 The C<delete_by_query_rethrottle()> API is used to dynamically update the throtting
1462 of an existing delete-by-query request, identified by C<task_id>.
1463  
1464 Query string parameters:
1465 C<error_trace>,
1466 C<filter_path>,
1467 C<human>,
1468 C<requests_per_second>
1469  
1470 See the L<delete-by-query-rethrottle docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html>
1471 for more information.
1472  
1473 =head2 C<reindex()>
1474  
1475 $response = $e->reindex(
1476 body => { reindex } # required
1477 );
1478  
1479 The C<reindex()> API is used to index documents from one index or multiple indices
1480 to a new index.
1481  
1482 Query string parameters:
1483 C<error_trace>,
1484 C<human>,
1485 C<refresh>,
1486 C<requests_per_second>,
1487 C<slices>,
1488 C<timeout>,
1489 C<wait_for_active_shards>,
1490 C<wait_for_completion>
1491  
1492 See the L<reindex docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>
1493 for more information.
1494  
1495 =head2 C<reindex_rethrottle()>
1496  
1497 $response = $e->delete_by_query_rethrottle(
1498 task_id => 'id', # required
1499 requests_per_second => num
1500 );
1501  
1502 The C<reindex_rethrottle()> API is used to dynamically update the throtting
1503 of an existing reindex request, identified by C<task_id>.
1504  
1505 Query string parameters:
1506 C<error_trace>,
1507 C<filter_path>,
1508 C<human>,
1509 C<requests_per_second>
1510  
1511 See the L<reindex-rethrottle docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>
1512 for more information.
1513  
1514 =head2 C<update_by_query()>
1515  
1516 $response = $e->update_by_query(
1517 index => 'index' | \@indices, # optional
1518 type => 'type' | \@types, # optional,
1519 body => { update-by-query } # optional
1520 );
1521  
1522 The C<update_by_query()> API is used to bulk update documents from one index or
1523 multiple indices using a script.
1524  
1525 Query string parameters:
1526 C<_source>,
1527 C<_source_excludes>,
1528 C<_source_includes>,
1529 C<allow_no_indices>,
1530 C<analyze_wildcard>,
1531 C<analyzer>,
1532 C<conflicts>,
1533 C<default_operator>,
1534 C<df>,
1535 C<error_trace>,
1536 C<expand_wildcards>,
1537 C<from>,
1538 C<human>,
1539 C<ignore_unavailable>,
1540 C<lenient>,
1541 C<pipeline>,
1542 C<preference>,
1543 C<q>,
1544 C<refresh>,
1545 C<request_cache>,
1546 C<requests_per_second>,
1547 C<routing>,
1548 C<scroll>,
1549 C<scroll_size>,
1550 C<search_timeout>,
1551 C<search_type>,
1552 C<size>,
1553 C<slices>,
1554 C<sort>,
1555 C<stats>,
1556 C<terminate_after>,
1557 C<timeout>,
1558 C<version>,
1559 C<version_type>,
1560 C<wait_for_active_shards>,
1561 C<wait_for_completion>
1562  
1563 See the L<update_by_query docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html>
1564 for more information.
1565  
1566 =head2 C<update_by_query_rethrottle()>
1567  
1568 $response = $e->update_by_query_rethrottle(
1569 task_id => 'id' # required
1570 requests_per_second => num
1571 );
1572  
1573 The C<update_by_query_rethrottle()> API is used to dynamically update the throtting
1574 of an existing update-by-query request, identified by C<task_id>.
1575  
1576 Query string parameters:
1577 C<error_trace>,
1578 C<filter_path>,
1579 C<human>,
1580 C<requests_per_second>
1581  
1582 See the L<update-by-query-rethrottle docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html>
1583 for more information.
1584  
1585 =head1 INDEXED SCRIPT METHODS
1586  
1587 Elasticsearch allows you to store scripts in the cluster state
1588 and reference them by id. The methods to manage indexed scripts are as follows:
1589  
1590 =head2 C<put_script()>
1591  
1592 $result = $e->put_script(
1593 id => 'id', # required
1594 context => $context, # optional
1595 body => { script } # required
1596 );
1597  
1598 The C<put_script()> method is used to store a script in the cluster state. For instance:
1599  
1600 $result = $e->put_scripts(
1601 id => 'hello_world',
1602 body => {
1603 script => {
1604 lang => 'painless',
1605 source => q(return "hello world")
1606 }
1607 }
1608 );
1609  
1610 Query string parameters:
1611 C<error_trace>,
1612 C<human>
1613  
1614 See the L<indexed scripts docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> for more.
1615  
1616 =head2 C<get_script()>
1617  
1618 $script = $e->get_script(
1619 id => 'id', # required
1620 );
1621  
1622 Retrieve the indexed script from the cluster state.
1623  
1624 Query string parameters:
1625 C<error_trace>,
1626 C<human>,
1627 C<master_timeout>
1628  
1629 See the L<indexed scripts docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> for more.
1630  
1631 =head2 C<delete_script()>
1632  
1633 $script = $e->delete_script(
1634 id => 'id', # required
1635 );
1636  
1637 Delete the indexed script from the cluster state.
1638  
1639 Query string parameters:
1640 C<error_trace>,
1641 C<human>,
1642 C<master_timeout>,
1643 C<timeout>
1644  
1645 See the L<indexed scripts docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> for more.
1646  
1647 =head2 C<scripts_painless_execute()>
1648  
1649 $result = $e->scripts_painless_execute(
1650 body => {...} # required
1651 );
1652  
1653 The Painless execute API allows an arbitrary script to be executed and a result to be returned.
1654  
1655 Query string parameters:
1656 C<error_trace>,
1657 C<filter_path>,
1658 C<human>
1659  
1660 See the L<painless execution docs|https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-execute-api.html> for more.
1661  
1662 =head1 AUTHOR
1663  
1664 Enrico Zimuel <enrico.zimuel@elastic.co>
1665  
1666 =head1 COPYRIGHT AND LICENSE
1667  
1668 This software is Copyright (c) 2020 by Elasticsearch BV.
1669  
1670 This is free software, licensed under:
1671  
1672 The Apache License, Version 2.0, January 2004
1673  
1674 =cut
1675  
1676 __END__
« Elasticsearch/Client/7_0/Role/API.pm ↑ Summary Elasticsearch/Role/CxnPool.pm »