-
Notifications
You must be signed in to change notification settings - Fork 973
/
Copy pathClient.php
1585 lines (1396 loc) · 71.4 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
namespace Elasticsearch;
use Elasticsearch\Common\Exceptions\BadMethodCallException;
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
use Elasticsearch\Common\Exceptions\BadRequest400Exception;
use Elasticsearch\Common\Exceptions\Missing404Exception;
use Elasticsearch\Common\Exceptions\TransportException;
use Elasticsearch\Endpoints\AbstractEndpoint;
use Elasticsearch\Namespaces\AbstractNamespace;
use Elasticsearch\Namespaces\CatNamespace;
use Elasticsearch\Namespaces\ClusterNamespace;
use Elasticsearch\Namespaces\IndicesNamespace;
use Elasticsearch\Namespaces\IngestNamespace;
use Elasticsearch\Namespaces\NamespaceBuilderInterface;
use Elasticsearch\Namespaces\NodesNamespace;
use Elasticsearch\Namespaces\RemoteNamespace;
use Elasticsearch\Namespaces\SnapshotNamespace;
use Elasticsearch\Namespaces\BooleanRequestWrapper;
use Elasticsearch\Namespaces\TasksNamespace;
/**
* Class Client
*
* @category Elasticsearch
* @package Elasticsearch
* @author Zachary Tong <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elastic.co
*/
class Client
{
const VERSION = '5.5.0';
/**
* @var Transport
*/
public $transport;
/**
* @var array
*/
protected $params;
/**
* @var IndicesNamespace
*/
protected $indices;
/**
* @var ClusterNamespace
*/
protected $cluster;
/**
* @var NodesNamespace
*/
protected $nodes;
/**
* @var SnapshotNamespace
*/
protected $snapshot;
/**
* @var CatNamespace
*/
protected $cat;
/**
* @var IngestNamespace
*/
protected $ingest;
/**
* @var TasksNamespace
*/
protected $tasks;
/**
* @var RemoteNamespace
*/
protected $remote;
/** @var callback */
protected $endpoints;
/** @var NamespaceBuilderInterface[] */
protected $registeredNamespaces = [];
/**
* Client constructor
*
* @param Transport $transport
* @param callable $endpoint
* @param AbstractNamespace[] $registeredNamespaces
*/
public function __construct(Transport $transport, callable $endpoint, array $registeredNamespaces)
{
$this->transport = $transport;
$this->endpoints = $endpoint;
$this->indices = new IndicesNamespace($transport, $endpoint);
$this->cluster = new ClusterNamespace($transport, $endpoint);
$this->nodes = new NodesNamespace($transport, $endpoint);
$this->snapshot = new SnapshotNamespace($transport, $endpoint);
$this->cat = new CatNamespace($transport, $endpoint);
$this->ingest = new IngestNamespace($transport, $endpoint);
$this->tasks = new TasksNamespace($transport, $endpoint);
$this->remote = new RemoteNamespace($transport, $endpoint);
$this->registeredNamespaces = $registeredNamespaces;
}
/**
* @param $params
* @return array
*/
public function info($params = [])
{
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Info $endpoint */
$endpoint = $endpointBuilder('Info');
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* @param $params array Associative array of parameters
*
* @return bool
*/
public function ping($params = [])
{
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Ping $endpoint */
$endpoint = $endpointBuilder('Ping');
$endpoint->setParams($params);
try {
$this->performRequest($endpoint);
} catch (Missing404Exception $exception) {
return false;
} catch (TransportException $exception) {
return false;
} catch (NoNodesAvailableException $exception) {
return false;
}
return true;
}
/**
* $params['id'] = (string) The document ID (Required)
* ['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (use `_all` to fetch the first document matching the ID across all types) (Required)
* ['ignore_missing'] = ??
* ['fields'] = (list) A comma-separated list of fields to return in the response
* ['parent'] = (string) The ID of the parent document
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['realtime'] = (boolean) Specify whether to perform the operation in realtime or search mode
* ['refresh'] = (boolean) Refresh the shard containing the document before performing the operation
* ['routing'] = (string) Specific routing value
* ['_source'] = (list) True or false to return the _source field or not, or a list of fields to return
* ['_source_exclude'] = (list) A list of fields to exclude from the returned _source field
* ['_source_include'] = (list) A list of fields to extract and return from the _source field
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function get($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Get $endpoint */
$endpoint = $endpointBuilder('Get');
$endpoint->setID($id)
->setIndex($index)
->setType($type);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['id'] = (string) The document ID (Required)
* ['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (use `_all` to fetch the first document matching the ID across all types) (Required)
* ['ignore_missing'] = ??
* ['parent'] = (string) The ID of the parent document
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['realtime'] = (boolean) Specify whether to perform the operation in realtime or search mode
* ['refresh'] = (boolean) Refresh the shard containing the document before performing the operation
* ['routing'] = (string) Specific routing value
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function getSource($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Get $endpoint */
$endpoint = $endpointBuilder('Get');
$endpoint->setID($id)
->setIndex($index)
->setType($type)
->returnOnlySource();
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['id'] = (string) The document ID (Required)
* ['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (Required)
* ['consistency'] = (enum) Specific write consistency setting for the operation
* ['parent'] = (string) ID of parent document
* ['refresh'] = (boolean) Refresh the index after performing the operation
* ['replication'] = (enum) Specific replication type
* ['routing'] = (string) Specific routing value
* ['timeout'] = (time) Explicit operation timeout
* ['version_type'] = (enum) Specific version type
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function delete($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$this->verifyNotNullOrEmpty("id", $id);
$this->verifyNotNullOrEmpty("type", $type);
$this->verifyNotNullOrEmpty("index", $index);
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Delete $endpoint */
$endpoint = $endpointBuilder('Delete');
$endpoint->setID($id)
->setIndex($index)
->setType($type);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
*
* $params['_source'] = (list) True or false to return the _source field or not, or a list of fields to return
* ['_source_exclude'] = (array) A list of fields to exclude from the returned _source field
* ['_source_include'] = (array) A list of fields to extract and return from the _source field
* ['allow_no_indices'] = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* ['analyze_wildcard'] = (bool) Specify whether wildcard and prefix queries should be analyzed (default: false)
* ['analyzer'] = (string) The analyzer to use for the query string
* ['conflicts'] = (enum) What to do when the delete-by-query hits version conflicts?
* ['default_operator'] = (enum) The default operator for query string query (AND or OR)
* ['df'] = (string) The field to use as default where no field prefix is given in the query string
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
* ['from'] = (number) Starting offset (default: 0)
* ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ['lenient'] = (bool) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['q'] = (string) Query in the Lucene query string syntax
* ['refresh'] = (bool) Should the effected indexes be refreshed?
* ['request_cache'] = (bool) Specify if request cache should be used for this request or not, defaults to index level setting
* ['requests_per_second'] = (number) The throttle for this request in sub-requests per second. -1 means no throttle.
* ['routing'] = (array) A comma-separated list of specific routing values
* ['scroll'] = (number) Specify how long a consistent view of the index should be maintained for scrolled search
* ['scroll_size'] = (number) Size on the scroll request powering the update_by_query
* ['search_timeout'] = (number) Explicit timeout for each search request. Defaults to no timeout.
* ['search_type'] = (enum) Search operation type
* ['size'] = (number) Number of hits to return (default: 10)
* ['slices'] = (integer) The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
* ['sort'] = (array) A comma-separated list of <field>:<direction> pairs
* ['stats'] = (array) Specific 'tag' of the request for logging and statistical purposes
* ['terminate_after'] = (number) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* ['timeout'] = (number) Time each individual bulk request should wait for shards that are unavailable.
* ['version'] = (bool) Specify whether to return document version as part of a hit
* ['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* ['wait_for_completion'] = (bool) Should the request should block until the delete-by-query is complete.
*
* @param array $params
*
* @return array
*/
public function deleteByQuery($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\DeleteByQuery $endpoint */
$endpoint = $endpointBuilder('DeleteByQuery');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of indices to restrict the results
* ['type'] = (list) A comma-separated list of types to restrict the results
* ['min_score'] = (number) Include only documents with a specific `_score` value in the result
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['routing'] = (string) Specific routing value
* ['source'] = (string) The URL-encoded query definition (instead of using the request body)
* ['body'] = (array) A query to restrict the results (optional)
* ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ['allow_no_indices'] = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function count($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Count $endpoint */
$endpoint = $endpointBuilder('Count');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of indices to restrict the results
* ['type'] = (list) A comma-separated list of types to restrict the results
* ['id'] = (string) ID of document
* ['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['routing'] = (string) Specific routing value
* ['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* ['body'] = (array) A query to restrict the results (optional)
* ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ['percolate_index'] = (string) The index to count percolate the document into. Defaults to index.
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
* ['version'] = (number) Explicit version number for concurrency control
* ['version_type'] = (enum) Specific version type
*
* @param $params array Associative array of parameters
*
* @return array
*
* @deprecated
*/
public function countPercolate($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$id = $this->extractArgument($params, 'id');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\CountPercolate $endpoint */
$endpoint = $endpointBuilder('CountPercolate');
$endpoint->setIndex($index)
->setType($type)
->setID($id)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) The name of the index with a registered percolator query (Required)
* ['type'] = (string) The document type (Required)
* ['prefer_local'] = (boolean) With `true`, specify that a local shard should be used if available, with `false`, use a random shard (default: true)
* ['body'] = (array) The document (`doc`) to percolate against registered queries; optionally also a `query` to limit the percolation to specific registered queries
*
* @param $params array Associative array of parameters
*
* @return array
*
* @deprecated
*/
public function percolate($params)
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$id = $this->extractArgument($params, 'id');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Percolate $endpoint */
$endpoint = $endpointBuilder('Percolate');
$endpoint->setIndex($index)
->setType($type)
->setID($id)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) Default index for items which don't provide one
* ['type'] = (string) Default document type for items which don't provide one
* ['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
*
* @param $params array Associative array of parameters
*
* @return array
*
* @deprecated
*/
public function mpercolate($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\MPercolate $endpoint */
$endpoint = $endpointBuilder('MPercolate');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) Default index for items which don't provide one
* ['type'] = (string) Default document type for items which don't provide one
* ['term_statistics'] = (boolean) Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['field_statistics'] = (boolean) Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['fields'] = (list) A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['offsets'] = (boolean) Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['positions'] = (boolean) Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['payloads'] = (boolean) Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['routing'] = (string) Specific routing value. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['parent'] = (string) Parent id of documents. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['realtime'] = (boolean) Specifies if request is real-time as opposed to near-real-time (default: true).
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function termvectors($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$id = $this->extractArgument($params, 'id');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\TermVectors $endpoint */
$endpoint = $endpointBuilder('TermVectors');
$endpoint->setIndex($index)
->setType($type)
->setID($id)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) Default index for items which don't provide one
* ['type'] = (string) Default document type for items which don't provide one
* ['ids'] = (list) A comma-separated list of documents ids. You must define ids as parameter or set \"ids\" or \"docs\" in the request body
* ['term_statistics'] = (boolean) Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['field_statistics'] = (boolean) Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['fields'] = (list) A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['offsets'] = (boolean) Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['positions'] = (boolean) Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."
* ['payloads'] = (boolean) Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['routing'] = (string) Specific routing value. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['parent'] = (string) Parent id of documents. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\".
* ['realtime'] = (boolean) Specifies if request is real-time as opposed to near-real-time (default: true).
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function mtermvectors($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\MTermVectors $endpoint */
$endpoint = $endpointBuilder('MTermVectors');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['id'] = (string) The document ID (Required)
* ['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (use `_all` to fetch the first document matching the ID across all types) (Required)
* ['parent'] = (string) The ID of the parent document
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['realtime'] = (boolean) Specify whether to perform the operation in realtime or search mode
* ['refresh'] = (boolean) Refresh the shard containing the document before performing the operation
* ['routing'] = (string) Specific routing value
*
* @param $params array Associative array of parameters
*
* @return array | boolean
*/
public function exists($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
//manually make this verbose so we can check status code
$params['client']['verbose'] = true;
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Exists $endpoint */
$endpoint = $endpointBuilder('Exists');
$endpoint->setID($id)
->setIndex($index)
->setType($type);
$endpoint->setParams($params);
return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
}
/**
* $params['index'] = (string) The name of the index
* ['type'] = (string) The type of the document
* ['fields'] = (list) A comma-separated list of fields to return in the response
* ['parent'] = (string) The ID of the parent document
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['realtime'] = (boolean) Specify whether to perform the operation in realtime or search mode
* ['refresh'] = (boolean) Refresh the shard containing the document before performing the operation
* ['routing'] = (string) Specific routing value
* ['body'] = (array) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL.
* ['_source'] = (list) True or false to return the _source field or not, or a list of fields to return
* ['_source_exclude'] = (list) A list of fields to exclude from the returned _source field
* ['_source_include'] = (list) A list of fields to extract and return from the _source field
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function mget($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Mget $endpoint */
$endpoint = $endpointBuilder('Mget');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of index names to use as default
* ['type'] = (list) A comma-separated list of document types to use as default
* ['search_type'] = (enum) Search operation type
* ['body'] = (array|string) The request definitions (metadata-search request definition pairs), separated by newlines
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function msearch($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Msearch $endpoint */
$endpoint = $endpointBuilder('Msearch');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of index names to use as default
* ['type'] = (list) A comma-separated list of document types to use as default
* ['search_type'] = (enum) Search operation type
* ['body'] = (array|string) The request definitions (metadata-search request definition pairs), separated by newlines
* ['max_concurrent_searches'] = (number) Controls the maximum number of concurrent searches the multi search api will execute
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function msearchTemplate($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\MsearchTemplate $endpoint */
$endpoint = $endpointBuilder('MsearchTemplate');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (Required)
* ['id'] = (string) Specific document ID (when the POST method is used)
* ['consistency'] = (enum) Explicit write consistency setting for the operation
* ['parent'] = (string) ID of the parent document
* ['refresh'] = (boolean) Refresh the index after performing the operation
* ['replication'] = (enum) Specific replication type
* ['routing'] = (string) Specific routing value
* ['timeout'] = (time) Explicit operation timeout
* ['timestamp'] = (time) Explicit timestamp for the document
* ['ttl'] = (duration) Expiration time for the document
* ['version'] = (number) Explicit version number for concurrency control
* ['version_type'] = (enum) Specific version type
* ['body'] = (array) The document
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function create($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Create $endpoint */
$endpoint = $endpointBuilder('Create');
$endpoint->setID($id)
->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) Default index for items which don't provide one
* ['type'] = (string) Default document type for items which don't provide one
* ['consistency'] = (enum) Explicit write consistency setting for the operation
* ['refresh'] = (boolean) Refresh the index after performing the operation
* ['replication'] = (enum) Explicitly set the replication type
* ['fields'] = (list) Default comma-separated list of fields to return in the response for updates
* ['body'] = (array) The document
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function bulk($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Bulk $endpoint */
$endpoint = $endpointBuilder('Bulk');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (Required)
* ['id'] = (string) Specific document ID (when the POST method is used)
* ['consistency'] = (enum) Explicit write consistency setting for the operation
* ['op_type'] = (enum) Explicit operation type
* ['parent'] = (string) ID of the parent document
* ['refresh'] = (boolean) Refresh the index after performing the operation
* ['replication'] = (enum) Specific replication type
* ['routing'] = (string) Specific routing value
* ['timeout'] = (time) Explicit operation timeout
* ['timestamp'] = (time) Explicit timestamp for the document
* ['ttl'] = (duration) Expiration time for the document
* ['version'] = (number) Explicit version number for concurrency control
* ['version_type'] = (enum) Specific version type
* ['body'] = (array) The document
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function index($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Index $endpoint */
$endpoint = $endpointBuilder('Index');
$endpoint->setID($id)
->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['refresh'] = (boolean) Should the effected indexes be refreshed?
* ['timeout'] = (time) Time each individual bulk request should wait for shards that are unavailable
* ['consistency'] = (enum) Explicit write consistency setting for the operation
* ['wait_for_completion'] = (boolean) Should the request should block until the reindex is complete
* ['requests_per_second'] = (float) The throttle for this request in sub-requests per second. 0 means set no throttle
* ['body'] = (array) The search definition using the Query DSL and the prototype for the index request (Required)
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function reindex($params)
{
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Reindex $endpoint */
$endpoint = $endpointBuilder('Reindex');
$endpoint->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
* ['ignore_indices'] = (enum) When performed on multiple indices, allows to ignore `missing` ones
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['routing'] = (string) Specific routing value
* ['source'] = (string) The URL-encoded request definition (instead of using request body)
* ['body'] = (array) The request definition
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function suggest($params = array())
{
$index = $this->extractArgument($params, 'index');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Suggest $endpoint */
$endpoint = $endpointBuilder('Suggest');
$endpoint->setIndex($index)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['id'] = (string) The document ID (Required)
* ['index'] = (string) The name of the index (Required)
* ['type'] = (string) The type of the document (Required)
* ['analyze_wildcard'] = (boolean) Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
* ['analyzer'] = (string) The analyzer for the query string query
* ['default_operator'] = (enum) The default operator for query string query (AND or OR)
* ['df'] = (string) The default field for query string query (default: _all)
* ['fields'] = (list) A comma-separated list of fields to return in the response
* ['lenient'] = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* ['lowercase_expanded_terms'] = (boolean) Specify whether query terms should be lowercased
* ['parent'] = (string) The ID of the parent document
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['q'] = (string) Query in the Lucene query string syntax
* ['routing'] = (string) Specific routing value
* ['source'] = (string) The URL-encoded query definition (instead of using the request body)
* ['_source'] = (list) True or false to return the _source field or not, or a list of fields to return
* ['_source_exclude'] = (list) A list of fields to exclude from the returned _source field
* ['_source_include'] = (list) A list of fields to extract and return from the _source field
* ['body'] = (string) The URL-encoded query definition (instead of using the request body)
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function explain($params)
{
$id = $this->extractArgument($params, 'id');
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Explain $endpoint */
$endpoint = $endpointBuilder('Explain');
$endpoint->setID($id)
->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* ['type'] = (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
* ['analyzer'] = (string) The analyzer to use for the query string
* ['analyze_wildcard'] = (boolean) Specify whether wildcard and prefix queries should be analyzed (default: false)
* ['default_operator'] = (enum) The default operator for query string query (AND or OR)
* ['df'] = (string) The field to use as default where no field prefix is given in the query string
* ['explain'] = (boolean) Specify whether to return detailed information about score computation as part of a hit
* ['fields'] = (list) A comma-separated list of fields to return as part of a hit
* ['from'] = (number) Starting offset (default: 0)
* ['ignore_indices'] = (enum) When performed on multiple indices, allows to ignore `missing` ones
* ['indices_boost'] = (list) Comma-separated list of index boosts
* ['lenient'] = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* ['lowercase_expanded_terms'] = (boolean) Specify whether query terms should be lowercased
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['q'] = (string) Query in the Lucene query string syntax
* ['query_cache'] = (boolean) Enable query cache for this request
* ['request_cache'] = (boolean) Enable request cache for this request
* ['routing'] = (list) A comma-separated list of specific routing values
* ['scroll'] = (duration) Specify how long a consistent view of the index should be maintained for scrolled search
* ['search_type'] = (enum) Search operation type
* ['size'] = (number) Number of hits to return (default: 10)
* ['sort'] = (list) A comma-separated list of <field>:<direction> pairs
* ['source'] = (string) The URL-encoded request definition using the Query DSL (instead of using request body)
* ['_source'] = (list) True or false to return the _source field or not, or a list of fields to return
* ['_source_exclude'] = (list) A list of fields to exclude from the returned _source field
* ['_source_include'] = (list) A list of fields to extract and return from the _source field
* ['stats'] = (list) Specific 'tag' of the request for logging and statistical purposes
* ['suggest_field'] = (string) Specify which field to use for suggestions
* ['suggest_mode'] = (enum) Specify suggest mode
* ['suggest_size'] = (number) How many suggestions to return in response
* ['suggest_text'] = (text) The source text for which the suggestions should be returned
* ['timeout'] = (time) Explicit operation timeout
* ['terminate_after'] = (number) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* ['version'] = (boolean) Specify whether to return document version as part of a hit
* ['body'] = (array|string) The search definition using the Query DSL
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function search($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\Search $endpoint */
$endpoint = $endpointBuilder('Search');
$endpoint->setIndex($index)
->setType($type)
->setBody($body);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* ['type'] = (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
* ['preference'] = (string) Specify the node or shard the operation should be performed on (default: random)
* ['routing'] = (string) Specific routing value
* ['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
* ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
* ['allow_no_indices'] = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function searchShards($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;
/** @var \Elasticsearch\Endpoints\SearchShards $endpoint */
$endpoint = $endpointBuilder('SearchShards');
$endpoint->setIndex($index)
->setType($type);
$endpoint->setParams($params);
return $this->performRequest($endpoint);
}
/**
* $params['index'] = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* ['type'] = (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function searchTemplate($params = array())
{
$index = $this->extractArgument($params, 'index');
$type = $this->extractArgument($params, 'type');
$body = $this->extractArgument($params, 'body');