File Coverage

blib/lib/Search/Elasticsearch/Client/8_0/Direct.pm
Criterion Covered Total %
statement 9 64 14.0
branch n/a
condition 0 12 0.0
subroutine 3 50 6.0
pod 2 2 100.0
total 14 128 10.9


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