8_0/Direct.pm untested

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