5_0/Direct.pm untested

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