5_0/Direct.pm untested

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