File Coverage

blib/lib/Search/Elasticsearch/Client/5_0/Direct.pm
Criterion Covered Total %
statement 15 29 51.7
branch n/a
condition 2 12 16.6
subroutine 5 15 33.3
pod 2 2 100.0
total 24 58 41.3


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