vendor/elasticsearch/elasticsearch/src/Traits/ClientEndpointsTrait.php line 1593

Open in your IDE?
  1. <?php
  2. /**
  3.  * Elasticsearch PHP Client
  4.  *
  5.  * @link      https://github.com/elastic/elasticsearch-php
  6.  * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
  7.  * @license   https://opensource.org/licenses/MIT MIT License
  8.  *
  9.  * Licensed to Elasticsearch B.V under one or more agreements.
  10.  * Elasticsearch B.V licenses this file to you under the MIT License.
  11.  * See the LICENSE file in the project root for more information.
  12.  */
  13. declare(strict_types=1);
  14. namespace Elastic\Elasticsearch\Traits;
  15. use Elastic\Elasticsearch\Exception\ClientResponseException;
  16. use Elastic\Elasticsearch\Exception\MissingParameterException;
  17. use Elastic\Elasticsearch\Exception\ServerResponseException;
  18. use Elastic\Elasticsearch\Response\Elasticsearch;
  19. use Elastic\Transport\Exception\NoNodeAvailableException;
  20. use Http\Promise\Promise;
  21. /**
  22.  * @generated This file is generated, please do not edit
  23.  */
  24. trait ClientEndpointsTrait
  25. {
  26.     /**
  27.      * Allows to perform multiple index/update/delete operations in a single request.
  28.      *
  29.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html
  30.      *
  31.      * @param array{
  32.      *     index: string, //  Default index for items which don't provide one
  33.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the bulk 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)
  34.      *     refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
  35.      *     routing: string, // Specific routing value
  36.      *     timeout: time, // Explicit operation timeout
  37.      *     type: string, // Default document type for items which don't provide one
  38.      *     _source: list, // True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
  39.      *     _source_excludes: list, // Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
  40.      *     _source_includes: list, // Default list of fields to extract and return from the _source field, can be overridden on each sub-request
  41.      *     pipeline: string, // The pipeline id to preprocess incoming documents with
  42.      *     require_alias: boolean, // Sets require_alias for all incoming documents. Defaults to unset (false)
  43.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  44.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  45.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  46.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  47.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  48.      *     body: array, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines
  49.      * } $params
  50.      *
  51.      * @throws NoNodeAvailableException if all the hosts are offline
  52.      * @throws ClientResponseException if the status code of response is 4xx
  53.      * @throws ServerResponseException if the status code of response is 5xx
  54.      *
  55.      * @return Elasticsearch|Promise
  56.      */
  57.     public function bulk(array $params = [])
  58.     {
  59.         $this->checkRequiredParameters(['body'], $params);
  60.         if (isset($params['index'])) {
  61.             $url '/' $this->encode($params['index']) . '/_bulk';
  62.             $method 'POST';
  63.         } else {
  64.             $url '/_bulk';
  65.             $method 'POST';
  66.         }
  67.         $url $this->addQueryString($url$params, ['wait_for_active_shards','refresh','routing','timeout','type','_source','_source_excludes','_source_includes','pipeline','require_alias','pretty','human','error_trace','source','filter_path']);
  68.         $headers = [
  69.             'Accept' => 'application/json',
  70.             'Content-Type' => 'application/x-ndjson',
  71.         ];
  72.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  73.     }
  74.     /**
  75.      * Explicitly clears the search context for a scroll.
  76.      *
  77.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html
  78.      *
  79.      * @param array{
  80.      *     scroll_id: list, //  A comma-separated list of scroll IDs to clear
  81.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  82.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  83.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  84.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  85.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  86.      *     body: array, //  A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
  87.      * } $params
  88.      *
  89.      * @throws NoNodeAvailableException if all the hosts are offline
  90.      * @throws ClientResponseException if the status code of response is 4xx
  91.      * @throws ServerResponseException if the status code of response is 5xx
  92.      *
  93.      * @return Elasticsearch|Promise
  94.      */
  95.     public function clearScroll(array $params = [])
  96.     {
  97.         if (isset($params['scroll_id'])) {
  98.             $url '/_search/scroll/' $this->encode($params['scroll_id']);
  99.             $method 'DELETE';
  100.         } else {
  101.             $url '/_search/scroll';
  102.             $method 'DELETE';
  103.         }
  104.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  105.         $headers = [
  106.             'Accept' => 'application/json',
  107.             'Content-Type' => 'application/json',
  108.         ];
  109.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  110.     }
  111.     /**
  112.      * Close a point in time
  113.      *
  114.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html
  115.      *
  116.      * @param array{
  117.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  118.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  119.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  120.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  121.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  122.      *     body: array, //  a point-in-time id to close
  123.      * } $params
  124.      *
  125.      * @throws NoNodeAvailableException if all the hosts are offline
  126.      * @throws ClientResponseException if the status code of response is 4xx
  127.      * @throws ServerResponseException if the status code of response is 5xx
  128.      *
  129.      * @return Elasticsearch|Promise
  130.      */
  131.     public function closePointInTime(array $params = [])
  132.     {
  133.         $url '/_pit';
  134.         $method 'DELETE';
  135.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  136.         $headers = [
  137.             'Accept' => 'application/json',
  138.             'Content-Type' => 'application/json',
  139.         ];
  140.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  141.     }
  142.     /**
  143.      * Returns number of documents matching a query.
  144.      *
  145.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html
  146.      *
  147.      * @param array{
  148.      *     index: list, //  A comma-separated list of indices to restrict the results
  149.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  150.      *     ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled
  151.      *     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)
  152.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  153.      *     min_score: number, // Include only documents with a specific `_score` value in the result
  154.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  155.      *     routing: list, // A comma-separated list of specific routing values
  156.      *     q: string, // Query in the Lucene query string syntax
  157.      *     analyzer: string, // The analyzer to use for the query string
  158.      *     analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false)
  159.      *     default_operator: enum, // The default operator for query string query (AND or OR)
  160.      *     df: string, // The field to use as default where no field prefix is given in the query string
  161.      *     lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  162.      *     terminate_after: number, // The maximum count for each shard, upon reaching which the query execution will terminate early
  163.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  164.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  165.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  166.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  167.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  168.      *     body: array, //  A query to restrict the results specified with the Query DSL (optional)
  169.      * } $params
  170.      *
  171.      * @throws NoNodeAvailableException if all the hosts are offline
  172.      * @throws ClientResponseException if the status code of response is 4xx
  173.      * @throws ServerResponseException if the status code of response is 5xx
  174.      *
  175.      * @return Elasticsearch|Promise
  176.      */
  177.     public function count(array $params = [])
  178.     {
  179.         if (isset($params['index'])) {
  180.             $url '/' $this->encode($params['index']) . '/_count';
  181.             $method = empty($params['body']) ? 'GET' 'POST';
  182.         } else {
  183.             $url '/_count';
  184.             $method = empty($params['body']) ? 'GET' 'POST';
  185.         }
  186.         $url $this->addQueryString($url$params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','min_score','preference','routing','q','analyzer','analyze_wildcard','default_operator','df','lenient','terminate_after','pretty','human','error_trace','source','filter_path']);
  187.         $headers = [
  188.             'Accept' => 'application/json',
  189.             'Content-Type' => 'application/json',
  190.         ];
  191.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  192.     }
  193.     /**
  194.      * Creates a new document in the index.
  195.      *
  196.      * Returns a 409 response when a document with a same ID already exists in the index.
  197.      *
  198.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html
  199.      *
  200.      * @param array{
  201.      *     id: string, // (REQUIRED) Document ID
  202.      *     index: string, // (REQUIRED) The name of the index
  203.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the index 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)
  204.      *     refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
  205.      *     routing: string, // Specific routing value
  206.      *     timeout: time, // Explicit operation timeout
  207.      *     version: number, // Explicit version number for concurrency control
  208.      *     version_type: enum, // Specific version type
  209.      *     pipeline: string, // The pipeline id to preprocess incoming documents with
  210.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  211.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  212.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  213.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  214.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  215.      *     body: array, // (REQUIRED) The document
  216.      * } $params
  217.      *
  218.      * @throws MissingParameterException if a required parameter is missing
  219.      * @throws NoNodeAvailableException if all the hosts are offline
  220.      * @throws ClientResponseException if the status code of response is 4xx
  221.      * @throws ServerResponseException if the status code of response is 5xx
  222.      *
  223.      * @return Elasticsearch|Promise
  224.      */
  225.     public function create(array $params = [])
  226.     {
  227.         $this->checkRequiredParameters(['id','index','body'], $params);
  228.         $url '/' $this->encode($params['index']) . '/_create/' $this->encode($params['id']);
  229.         $method 'PUT';
  230.         $url $this->addQueryString($url$params, ['wait_for_active_shards','refresh','routing','timeout','version','version_type','pipeline','pretty','human','error_trace','source','filter_path']);
  231.         $headers = [
  232.             'Accept' => 'application/json',
  233.             'Content-Type' => 'application/json',
  234.         ];
  235.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  236.     }
  237.     /**
  238.      * Removes a document from the index.
  239.      *
  240.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html
  241.      *
  242.      * @param array{
  243.      *     id: string, // (REQUIRED) The document ID
  244.      *     index: string, // (REQUIRED) The name of the index
  245.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the delete 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)
  246.      *     refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
  247.      *     routing: string, // Specific routing value
  248.      *     timeout: time, // Explicit operation timeout
  249.      *     if_seq_no: number, // only perform the delete operation if the last operation that has changed the document has the specified sequence number
  250.      *     if_primary_term: number, // only perform the delete operation if the last operation that has changed the document has the specified primary term
  251.      *     version: number, // Explicit version number for concurrency control
  252.      *     version_type: enum, // Specific version type
  253.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  254.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  255.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  256.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  257.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  258.      * } $params
  259.      *
  260.      * @throws MissingParameterException if a required parameter is missing
  261.      * @throws NoNodeAvailableException if all the hosts are offline
  262.      * @throws ClientResponseException if the status code of response is 4xx
  263.      * @throws ServerResponseException if the status code of response is 5xx
  264.      *
  265.      * @return Elasticsearch|Promise
  266.      */
  267.     public function delete(array $params = [])
  268.     {
  269.         $this->checkRequiredParameters(['id','index'], $params);
  270.         $url '/' $this->encode($params['index']) . '/_doc/' $this->encode($params['id']);
  271.         $method 'DELETE';
  272.         $url $this->addQueryString($url$params, ['wait_for_active_shards','refresh','routing','timeout','if_seq_no','if_primary_term','version','version_type','pretty','human','error_trace','source','filter_path']);
  273.         $headers = [
  274.             'Accept' => 'application/json',
  275.         ];
  276.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  277.     }
  278.     /**
  279.      * Deletes documents matching the provided query.
  280.      *
  281.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html
  282.      *
  283.      * @param array{
  284.      *     index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  285.      *     analyzer: string, // The analyzer to use for the query string
  286.      *     analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false)
  287.      *     default_operator: enum, // The default operator for query string query (AND or OR)
  288.      *     df: string, // The field to use as default where no field prefix is given in the query string
  289.      *     from: number, // Starting offset (default: 0)
  290.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  291.      *     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)
  292.      *     conflicts: enum, // What to do when the delete by query hits version conflicts?
  293.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  294.      *     lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  295.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  296.      *     q: string, // Query in the Lucene query string syntax
  297.      *     routing: list, // A comma-separated list of specific routing values
  298.      *     scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search
  299.      *     search_type: enum, // Search operation type
  300.      *     search_timeout: time, // Explicit timeout for each search request. Defaults to no timeout.
  301.      *     max_docs: number, // Maximum number of documents to process (default: all documents)
  302.      *     sort: list, // A comma-separated list of <field>:<direction> pairs
  303.      *     terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  304.      *     stats: list, // Specific 'tag' of the request for logging and statistical purposes
  305.      *     version: boolean, // Specify whether to return document version as part of a hit
  306.      *     request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to index level setting
  307.      *     refresh: boolean, // Should the affected indexes be refreshed?
  308.      *     timeout: time, // Time each individual bulk request should wait for shards that are unavailable.
  309.      *     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)
  310.      *     scroll_size: number, // Size on the scroll request powering the delete by query
  311.      *     wait_for_completion: boolean, // Should the request should block until the delete by query is complete.
  312.      *     requests_per_second: number, // The throttle for this request in sub-requests per second. -1 means no throttle.
  313.      *     slices: number|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`.
  314.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  315.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  316.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  317.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  318.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  319.      *     body: array, // (REQUIRED) The search definition using the Query DSL
  320.      * } $params
  321.      *
  322.      * @throws MissingParameterException if a required parameter is missing
  323.      * @throws NoNodeAvailableException if all the hosts are offline
  324.      * @throws ClientResponseException if the status code of response is 4xx
  325.      * @throws ServerResponseException if the status code of response is 5xx
  326.      *
  327.      * @return Elasticsearch|Promise
  328.      */
  329.     public function deleteByQuery(array $params = [])
  330.     {
  331.         $this->checkRequiredParameters(['index','body'], $params);
  332.         $url '/' $this->encode($params['index']) . '/_delete_by_query';
  333.         $method 'POST';
  334.         $url $this->addQueryString($url$params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']);
  335.         $headers = [
  336.             'Accept' => 'application/json',
  337.             'Content-Type' => 'application/json',
  338.         ];
  339.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  340.     }
  341.     /**
  342.      * Changes the number of requests per second for a particular Delete By Query operation.
  343.      *
  344.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
  345.      *
  346.      * @param array{
  347.      *     task_id: string, // (REQUIRED) The task id to rethrottle
  348.      *     requests_per_second: number, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
  349.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  350.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  351.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  352.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  353.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  354.      * } $params
  355.      *
  356.      * @throws MissingParameterException if a required parameter is missing
  357.      * @throws NoNodeAvailableException if all the hosts are offline
  358.      * @throws ClientResponseException if the status code of response is 4xx
  359.      * @throws ServerResponseException if the status code of response is 5xx
  360.      *
  361.      * @return Elasticsearch|Promise
  362.      */
  363.     public function deleteByQueryRethrottle(array $params = [])
  364.     {
  365.         $this->checkRequiredParameters(['task_id','requests_per_second'], $params);
  366.         $url '/_delete_by_query/' $this->encode($params['task_id']) . '/_rethrottle';
  367.         $method 'POST';
  368.         $url $this->addQueryString($url$params, ['requests_per_second','pretty','human','error_trace','source','filter_path']);
  369.         $headers = [
  370.             'Accept' => 'application/json',
  371.         ];
  372.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  373.     }
  374.     /**
  375.      * Deletes a script.
  376.      *
  377.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
  378.      *
  379.      * @param array{
  380.      *     id: string, // (REQUIRED) Script ID
  381.      *     timeout: time, // Explicit operation timeout
  382.      *     master_timeout: time, // Specify timeout for connection to master
  383.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  384.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  385.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  386.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  387.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  388.      * } $params
  389.      *
  390.      * @throws MissingParameterException if a required parameter is missing
  391.      * @throws NoNodeAvailableException if all the hosts are offline
  392.      * @throws ClientResponseException if the status code of response is 4xx
  393.      * @throws ServerResponseException if the status code of response is 5xx
  394.      *
  395.      * @return Elasticsearch|Promise
  396.      */
  397.     public function deleteScript(array $params = [])
  398.     {
  399.         $this->checkRequiredParameters(['id'], $params);
  400.         $url '/_scripts/' $this->encode($params['id']);
  401.         $method 'DELETE';
  402.         $url $this->addQueryString($url$params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
  403.         $headers = [
  404.             'Accept' => 'application/json',
  405.         ];
  406.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  407.     }
  408.     /**
  409.      * Returns information about whether a document exists in an index.
  410.      *
  411.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
  412.      *
  413.      * @param array{
  414.      *     id: string, // (REQUIRED) The document ID
  415.      *     index: string, // (REQUIRED) The name of the index
  416.      *     stored_fields: list, // A comma-separated list of stored fields to return in the response
  417.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  418.      *     realtime: boolean, // Specify whether to perform the operation in realtime or search mode
  419.      *     refresh: boolean, // Refresh the shard containing the document before performing the operation
  420.      *     routing: string, // Specific routing value
  421.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  422.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  423.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  424.      *     version: number, // Explicit version number for concurrency control
  425.      *     version_type: enum, // Specific version type
  426.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  427.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  428.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  429.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  430.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  431.      * } $params
  432.      *
  433.      * @throws MissingParameterException if a required parameter is missing
  434.      * @throws NoNodeAvailableException if all the hosts are offline
  435.      * @throws ClientResponseException if the status code of response is 4xx
  436.      * @throws ServerResponseException if the status code of response is 5xx
  437.      *
  438.      * @return Elasticsearch|Promise
  439.      */
  440.     public function exists(array $params = [])
  441.     {
  442.         $this->checkRequiredParameters(['id','index'], $params);
  443.         $url '/' $this->encode($params['index']) . '/_doc/' $this->encode($params['id']);
  444.         $method 'HEAD';
  445.         $url $this->addQueryString($url$params, ['stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
  446.         $headers = [
  447.             'Accept' => 'application/json',
  448.         ];
  449.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  450.     }
  451.     /**
  452.      * Returns information about whether a document source exists in an index.
  453.      *
  454.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
  455.      *
  456.      * @param array{
  457.      *     id: string, // (REQUIRED) The document ID
  458.      *     index: string, // (REQUIRED) The name of the index
  459.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  460.      *     realtime: boolean, // Specify whether to perform the operation in realtime or search mode
  461.      *     refresh: boolean, // Refresh the shard containing the document before performing the operation
  462.      *     routing: string, // Specific routing value
  463.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  464.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  465.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  466.      *     version: number, // Explicit version number for concurrency control
  467.      *     version_type: enum, // Specific version type
  468.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  469.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  470.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  471.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  472.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  473.      * } $params
  474.      *
  475.      * @throws MissingParameterException if a required parameter is missing
  476.      * @throws NoNodeAvailableException if all the hosts are offline
  477.      * @throws ClientResponseException if the status code of response is 4xx
  478.      * @throws ServerResponseException if the status code of response is 5xx
  479.      *
  480.      * @return Elasticsearch|Promise
  481.      */
  482.     public function existsSource(array $params = [])
  483.     {
  484.         $this->checkRequiredParameters(['id','index'], $params);
  485.         $url '/' $this->encode($params['index']) . '/_source/' $this->encode($params['id']);
  486.         $method 'HEAD';
  487.         $url $this->addQueryString($url$params, ['preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
  488.         $headers = [
  489.             'Accept' => 'application/json',
  490.         ];
  491.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  492.     }
  493.     /**
  494.      * Returns information about why a specific matches (or doesn't match) a query.
  495.      *
  496.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html
  497.      *
  498.      * @param array{
  499.      *     id: string, // (REQUIRED) The document ID
  500.      *     index: string, // (REQUIRED) The name of the index
  501.      *     analyze_wildcard: boolean, // Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
  502.      *     analyzer: string, // The analyzer for the query string query
  503.      *     default_operator: enum, // The default operator for query string query (AND or OR)
  504.      *     df: string, // The default field for query string query (default: _all)
  505.      *     stored_fields: list, // A comma-separated list of stored fields to return in the response
  506.      *     lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  507.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  508.      *     q: string, // Query in the Lucene query string syntax
  509.      *     routing: string, // Specific routing value
  510.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  511.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  512.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  513.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  514.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  515.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  516.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  517.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  518.      *     body: array, //  The query definition using the Query DSL
  519.      * } $params
  520.      *
  521.      * @throws MissingParameterException if a required parameter is missing
  522.      * @throws NoNodeAvailableException if all the hosts are offline
  523.      * @throws ClientResponseException if the status code of response is 4xx
  524.      * @throws ServerResponseException if the status code of response is 5xx
  525.      *
  526.      * @return Elasticsearch|Promise
  527.      */
  528.     public function explain(array $params = [])
  529.     {
  530.         $this->checkRequiredParameters(['id','index'], $params);
  531.         $url '/' $this->encode($params['index']) . '/_explain/' $this->encode($params['id']);
  532.         $method = empty($params['body']) ? 'GET' 'POST';
  533.         $url $this->addQueryString($url$params, ['analyze_wildcard','analyzer','default_operator','df','stored_fields','lenient','preference','q','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']);
  534.         $headers = [
  535.             'Accept' => 'application/json',
  536.             'Content-Type' => 'application/json',
  537.         ];
  538.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  539.     }
  540.     /**
  541.      * Returns the information about the capabilities of fields among multiple indices.
  542.      *
  543.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html
  544.      *
  545.      * @param array{
  546.      *     index: list, //  A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  547.      *     fields: list, // A comma-separated list of field names
  548.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  549.      *     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)
  550.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  551.      *     include_unmapped: boolean, // Indicates whether unmapped fields should be included in the response.
  552.      *     filters: list, // An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent
  553.      *     types: list, // Only return results for fields that have one of the types in the list
  554.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  555.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  556.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  557.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  558.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  559.      *     body: array, //  An index filter specified with the Query DSL
  560.      * } $params
  561.      *
  562.      * @throws NoNodeAvailableException if all the hosts are offline
  563.      * @throws ClientResponseException if the status code of response is 4xx
  564.      * @throws ServerResponseException if the status code of response is 5xx
  565.      *
  566.      * @return Elasticsearch|Promise
  567.      */
  568.     public function fieldCaps(array $params = [])
  569.     {
  570.         if (isset($params['index'])) {
  571.             $url '/' $this->encode($params['index']) . '/_field_caps';
  572.             $method = empty($params['body']) ? 'GET' 'POST';
  573.         } else {
  574.             $url '/_field_caps';
  575.             $method = empty($params['body']) ? 'GET' 'POST';
  576.         }
  577.         $url $this->addQueryString($url$params, ['fields','ignore_unavailable','allow_no_indices','expand_wildcards','include_unmapped','filters','types','pretty','human','error_trace','source','filter_path']);
  578.         $headers = [
  579.             'Accept' => 'application/json',
  580.             'Content-Type' => 'application/json',
  581.         ];
  582.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  583.     }
  584.     /**
  585.      * Returns a document.
  586.      *
  587.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
  588.      *
  589.      * @param array{
  590.      *     id: string, // (REQUIRED) The document ID
  591.      *     index: string, // (REQUIRED) The name of the index
  592.      *     force_synthetic_source: boolean, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index.
  593.      *     stored_fields: list, // A comma-separated list of stored fields to return in the response
  594.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  595.      *     realtime: boolean, // Specify whether to perform the operation in realtime or search mode
  596.      *     refresh: boolean, // Refresh the shard containing the document before performing the operation
  597.      *     routing: string, // Specific routing value
  598.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  599.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  600.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  601.      *     version: number, // Explicit version number for concurrency control
  602.      *     version_type: enum, // Specific version type
  603.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  604.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  605.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  606.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  607.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  608.      * } $params
  609.      *
  610.      * @throws MissingParameterException if a required parameter is missing
  611.      * @throws NoNodeAvailableException if all the hosts are offline
  612.      * @throws ClientResponseException if the status code of response is 4xx
  613.      * @throws ServerResponseException if the status code of response is 5xx
  614.      *
  615.      * @return Elasticsearch|Promise
  616.      */
  617.     public function get(array $params = [])
  618.     {
  619.         $this->checkRequiredParameters(['id','index'], $params);
  620.         $url '/' $this->encode($params['index']) . '/_doc/' $this->encode($params['id']);
  621.         $method 'GET';
  622.         $url $this->addQueryString($url$params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
  623.         $headers = [
  624.             'Accept' => 'application/json',
  625.         ];
  626.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  627.     }
  628.     /**
  629.      * Returns a script.
  630.      *
  631.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
  632.      *
  633.      * @param array{
  634.      *     id: string, // (REQUIRED) Script ID
  635.      *     master_timeout: time, // Specify timeout for connection to master
  636.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  637.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  638.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  639.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  640.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  641.      * } $params
  642.      *
  643.      * @throws MissingParameterException if a required parameter is missing
  644.      * @throws NoNodeAvailableException if all the hosts are offline
  645.      * @throws ClientResponseException if the status code of response is 4xx
  646.      * @throws ServerResponseException if the status code of response is 5xx
  647.      *
  648.      * @return Elasticsearch|Promise
  649.      */
  650.     public function getScript(array $params = [])
  651.     {
  652.         $this->checkRequiredParameters(['id'], $params);
  653.         $url '/_scripts/' $this->encode($params['id']);
  654.         $method 'GET';
  655.         $url $this->addQueryString($url$params, ['master_timeout','pretty','human','error_trace','source','filter_path']);
  656.         $headers = [
  657.             'Accept' => 'application/json',
  658.         ];
  659.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  660.     }
  661.     /**
  662.      * Returns all script contexts.
  663.      *
  664.      * @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html
  665.      *
  666.      * @param array{
  667.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  668.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  669.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  670.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  671.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  672.      * } $params
  673.      *
  674.      * @throws NoNodeAvailableException if all the hosts are offline
  675.      * @throws ClientResponseException if the status code of response is 4xx
  676.      * @throws ServerResponseException if the status code of response is 5xx
  677.      *
  678.      * @return Elasticsearch|Promise
  679.      */
  680.     public function getScriptContext(array $params = [])
  681.     {
  682.         $url '/_script_context';
  683.         $method 'GET';
  684.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  685.         $headers = [
  686.             'Accept' => 'application/json',
  687.         ];
  688.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  689.     }
  690.     /**
  691.      * Returns available script types, languages and contexts
  692.      *
  693.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
  694.      *
  695.      * @param array{
  696.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  697.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  698.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  699.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  700.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  701.      * } $params
  702.      *
  703.      * @throws NoNodeAvailableException if all the hosts are offline
  704.      * @throws ClientResponseException if the status code of response is 4xx
  705.      * @throws ServerResponseException if the status code of response is 5xx
  706.      *
  707.      * @return Elasticsearch|Promise
  708.      */
  709.     public function getScriptLanguages(array $params = [])
  710.     {
  711.         $url '/_script_language';
  712.         $method 'GET';
  713.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  714.         $headers = [
  715.             'Accept' => 'application/json',
  716.         ];
  717.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  718.     }
  719.     /**
  720.      * Returns the source of a document.
  721.      *
  722.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
  723.      *
  724.      * @param array{
  725.      *     id: string, // (REQUIRED) The document ID
  726.      *     index: string, // (REQUIRED) The name of the index
  727.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  728.      *     realtime: boolean, // Specify whether to perform the operation in realtime or search mode
  729.      *     refresh: boolean, // Refresh the shard containing the document before performing the operation
  730.      *     routing: string, // Specific routing value
  731.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  732.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  733.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  734.      *     version: number, // Explicit version number for concurrency control
  735.      *     version_type: enum, // Specific version type
  736.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  737.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  738.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  739.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  740.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  741.      * } $params
  742.      *
  743.      * @throws MissingParameterException if a required parameter is missing
  744.      * @throws NoNodeAvailableException if all the hosts are offline
  745.      * @throws ClientResponseException if the status code of response is 4xx
  746.      * @throws ServerResponseException if the status code of response is 5xx
  747.      *
  748.      * @return Elasticsearch|Promise
  749.      */
  750.     public function getSource(array $params = [])
  751.     {
  752.         $this->checkRequiredParameters(['id','index'], $params);
  753.         $url '/' $this->encode($params['index']) . '/_source/' $this->encode($params['id']);
  754.         $method 'GET';
  755.         $url $this->addQueryString($url$params, ['preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
  756.         $headers = [
  757.             'Accept' => 'application/json',
  758.         ];
  759.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  760.     }
  761.     /**
  762.      * Returns the health of the cluster.
  763.      *
  764.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/health-api.html
  765.      *
  766.      * @param array{
  767.      *     feature: string, //  A feature of the cluster, as returned by the top-level health API
  768.      *     timeout: time, // Explicit operation timeout
  769.      *     verbose: boolean, // Opt in for more information about the health of the system
  770.      *     size: int, // Limit the number of affected resources the health API returns
  771.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  772.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  773.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  774.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  775.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  776.      * } $params
  777.      *
  778.      * @throws NoNodeAvailableException if all the hosts are offline
  779.      * @throws ClientResponseException if the status code of response is 4xx
  780.      * @throws ServerResponseException if the status code of response is 5xx
  781.      *
  782.      * @return Elasticsearch|Promise
  783.      */
  784.     public function healthReport(array $params = [])
  785.     {
  786.         if (isset($params['feature'])) {
  787.             $url '/_health_report/' $this->encode($params['feature']);
  788.             $method 'GET';
  789.         } else {
  790.             $url '/_health_report';
  791.             $method 'GET';
  792.         }
  793.         $url $this->addQueryString($url$params, ['timeout','verbose','size','pretty','human','error_trace','source','filter_path']);
  794.         $headers = [
  795.             'Accept' => 'application/json',
  796.         ];
  797.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  798.     }
  799.     /**
  800.      * Creates or updates a document in an index.
  801.      *
  802.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html
  803.      *
  804.      * @param array{
  805.      *     id: string, //  Document ID
  806.      *     index: string, // (REQUIRED) The name of the index
  807.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the index 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)
  808.      *     op_type: enum, // Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID
  809.      *     refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
  810.      *     routing: string, // Specific routing value
  811.      *     timeout: time, // Explicit operation timeout
  812.      *     version: number, // Explicit version number for concurrency control
  813.      *     version_type: enum, // Specific version type
  814.      *     if_seq_no: number, // only perform the index operation if the last operation that has changed the document has the specified sequence number
  815.      *     if_primary_term: number, // only perform the index operation if the last operation that has changed the document has the specified primary term
  816.      *     pipeline: string, // The pipeline id to preprocess incoming documents with
  817.      *     require_alias: boolean, // When true, requires destination to be an alias. Default is false
  818.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  819.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  820.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  821.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  822.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  823.      *     body: array, // (REQUIRED) The document
  824.      * } $params
  825.      *
  826.      * @throws MissingParameterException if a required parameter is missing
  827.      * @throws NoNodeAvailableException if all the hosts are offline
  828.      * @throws ClientResponseException if the status code of response is 4xx
  829.      * @throws ServerResponseException if the status code of response is 5xx
  830.      *
  831.      * @return Elasticsearch|Promise
  832.      */
  833.     public function index(array $params = [])
  834.     {
  835.         $this->checkRequiredParameters(['index','body'], $params);
  836.         if (isset($params['id'])) {
  837.             $url '/' $this->encode($params['index']) . '/_doc/' $this->encode($params['id']);
  838.             $method 'PUT';
  839.         } else {
  840.             $url '/' $this->encode($params['index']) . '/_doc';
  841.             $method 'POST';
  842.         }
  843.         $url $this->addQueryString($url$params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','pretty','human','error_trace','source','filter_path']);
  844.         $headers = [
  845.             'Accept' => 'application/json',
  846.             'Content-Type' => 'application/json',
  847.         ];
  848.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  849.     }
  850.     /**
  851.      * Returns basic information about the cluster.
  852.      *
  853.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
  854.      *
  855.      * @param array{
  856.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  857.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  858.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  859.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  860.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  861.      * } $params
  862.      *
  863.      * @throws NoNodeAvailableException if all the hosts are offline
  864.      * @throws ClientResponseException if the status code of response is 4xx
  865.      * @throws ServerResponseException if the status code of response is 5xx
  866.      *
  867.      * @return Elasticsearch|Promise
  868.      */
  869.     public function info(array $params = [])
  870.     {
  871.         $url '/';
  872.         $method 'GET';
  873.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  874.         $headers = [
  875.             'Accept' => 'application/json',
  876.         ];
  877.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  878.     }
  879.     /**
  880.      * Performs a kNN search.
  881.      *
  882.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html
  883.      * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
  884.      *
  885.      * @param array{
  886.      *     index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` to perform the operation on all indices
  887.      *     routing: list, // A comma-separated list of specific routing values
  888.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  889.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  890.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  891.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  892.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  893.      *     body: array, //  The search definition
  894.      * } $params
  895.      *
  896.      * @throws MissingParameterException if a required parameter is missing
  897.      * @throws NoNodeAvailableException if all the hosts are offline
  898.      * @throws ClientResponseException if the status code of response is 4xx
  899.      * @throws ServerResponseException if the status code of response is 5xx
  900.      *
  901.      * @return Elasticsearch|Promise
  902.      */
  903.     public function knnSearch(array $params = [])
  904.     {
  905.         $this->checkRequiredParameters(['index'], $params);
  906.         $url '/' $this->encode($params['index']) . '/_knn_search';
  907.         $method = empty($params['body']) ? 'GET' 'POST';
  908.         $url $this->addQueryString($url$params, ['routing','pretty','human','error_trace','source','filter_path']);
  909.         $headers = [
  910.             'Accept' => 'application/json',
  911.             'Content-Type' => 'application/json',
  912.         ];
  913.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  914.     }
  915.     /**
  916.      * Allows to get multiple documents in one request.
  917.      *
  918.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html
  919.      *
  920.      * @param array{
  921.      *     index: string, //  The name of the index
  922.      *     force_synthetic_source: boolean, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index.
  923.      *     stored_fields: list, // A comma-separated list of stored fields to return in the response
  924.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  925.      *     realtime: boolean, // Specify whether to perform the operation in realtime or search mode
  926.      *     refresh: boolean, // Refresh the shard containing the document before performing the operation
  927.      *     routing: string, // Specific routing value
  928.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  929.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  930.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  931.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  932.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  933.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  934.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  935.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  936.      *     body: array, // (REQUIRED) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL.
  937.      * } $params
  938.      *
  939.      * @throws NoNodeAvailableException if all the hosts are offline
  940.      * @throws ClientResponseException if the status code of response is 4xx
  941.      * @throws ServerResponseException if the status code of response is 5xx
  942.      *
  943.      * @return Elasticsearch|Promise
  944.      */
  945.     public function mget(array $params = [])
  946.     {
  947.         $this->checkRequiredParameters(['body'], $params);
  948.         if (isset($params['index'])) {
  949.             $url '/' $this->encode($params['index']) . '/_mget';
  950.             $method = empty($params['body']) ? 'GET' 'POST';
  951.         } else {
  952.             $url '/_mget';
  953.             $method = empty($params['body']) ? 'GET' 'POST';
  954.         }
  955.         $url $this->addQueryString($url$params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']);
  956.         $headers = [
  957.             'Accept' => 'application/json',
  958.             'Content-Type' => 'application/json',
  959.         ];
  960.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  961.     }
  962.     /**
  963.      * Allows to execute several search operations in one request.
  964.      *
  965.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html
  966.      *
  967.      * @param array{
  968.      *     index: list, //  A comma-separated list of index names to use as default
  969.      *     search_type: enum, // Search operation type
  970.      *     max_concurrent_searches: number, // Controls the maximum number of concurrent searches the multi search api will execute
  971.      *     typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  972.      *     pre_filter_shard_size: number, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
  973.      *     max_concurrent_shard_requests: number, // The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
  974.      *     rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  975.      *     ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  976.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  977.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  978.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  979.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  980.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  981.      *     body: array, // (REQUIRED) The request definitions (metadata-search request definition pairs), separated by newlines
  982.      * } $params
  983.      *
  984.      * @throws NoNodeAvailableException if all the hosts are offline
  985.      * @throws ClientResponseException if the status code of response is 4xx
  986.      * @throws ServerResponseException if the status code of response is 5xx
  987.      *
  988.      * @return Elasticsearch|Promise
  989.      */
  990.     public function msearch(array $params = [])
  991.     {
  992.         $this->checkRequiredParameters(['body'], $params);
  993.         if (isset($params['index'])) {
  994.             $url '/' $this->encode($params['index']) . '/_msearch';
  995.             $method = empty($params['body']) ? 'GET' 'POST';
  996.         } else {
  997.             $url '/_msearch';
  998.             $method = empty($params['body']) ? 'GET' 'POST';
  999.         }
  1000.         $url $this->addQueryString($url$params, ['search_type','max_concurrent_searches','typed_keys','pre_filter_shard_size','max_concurrent_shard_requests','rest_total_hits_as_int','ccs_minimize_roundtrips','pretty','human','error_trace','source','filter_path']);
  1001.         $headers = [
  1002.             'Accept' => 'application/json',
  1003.             'Content-Type' => 'application/x-ndjson',
  1004.         ];
  1005.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1006.     }
  1007.     /**
  1008.      * Allows to execute several search template operations in one request.
  1009.      *
  1010.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
  1011.      *
  1012.      * @param array{
  1013.      *     index: list, //  A comma-separated list of index names to use as default
  1014.      *     search_type: enum, // Search operation type
  1015.      *     typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  1016.      *     max_concurrent_searches: number, // Controls the maximum number of concurrent searches the multi search api will execute
  1017.      *     rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  1018.      *     ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  1019.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1020.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1021.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1022.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1023.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1024.      *     body: array, // (REQUIRED) The request definitions (metadata-search request definition pairs), separated by newlines
  1025.      * } $params
  1026.      *
  1027.      * @throws NoNodeAvailableException if all the hosts are offline
  1028.      * @throws ClientResponseException if the status code of response is 4xx
  1029.      * @throws ServerResponseException if the status code of response is 5xx
  1030.      *
  1031.      * @return Elasticsearch|Promise
  1032.      */
  1033.     public function msearchTemplate(array $params = [])
  1034.     {
  1035.         $this->checkRequiredParameters(['body'], $params);
  1036.         if (isset($params['index'])) {
  1037.             $url '/' $this->encode($params['index']) . '/_msearch/template';
  1038.             $method = empty($params['body']) ? 'GET' 'POST';
  1039.         } else {
  1040.             $url '/_msearch/template';
  1041.             $method = empty($params['body']) ? 'GET' 'POST';
  1042.         }
  1043.         $url $this->addQueryString($url$params, ['search_type','typed_keys','max_concurrent_searches','rest_total_hits_as_int','ccs_minimize_roundtrips','pretty','human','error_trace','source','filter_path']);
  1044.         $headers = [
  1045.             'Accept' => 'application/json',
  1046.             'Content-Type' => 'application/x-ndjson',
  1047.         ];
  1048.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1049.     }
  1050.     /**
  1051.      * Returns multiple termvectors in one request.
  1052.      *
  1053.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html
  1054.      *
  1055.      * @param array{
  1056.      *     index: string, //  The index in which the document resides.
  1057.      *     ids: list, // A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body
  1058.      *     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".
  1059.      *     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".
  1060.      *     fields: list, // A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs".
  1061.      *     offsets: boolean, // Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
  1062.      *     positions: boolean, // Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
  1063.      *     payloads: boolean, // Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs".
  1064.      *     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".
  1065.      *     routing: string, // Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs".
  1066.      *     realtime: boolean, // Specifies if requests are real-time as opposed to near-real-time (default: true).
  1067.      *     version: number, // Explicit version number for concurrency control
  1068.      *     version_type: enum, // Specific version type
  1069.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1070.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1071.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1072.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1073.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1074.      *     body: array, //  Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
  1075.      * } $params
  1076.      *
  1077.      * @throws NoNodeAvailableException if all the hosts are offline
  1078.      * @throws ClientResponseException if the status code of response is 4xx
  1079.      * @throws ServerResponseException if the status code of response is 5xx
  1080.      *
  1081.      * @return Elasticsearch|Promise
  1082.      */
  1083.     public function mtermvectors(array $params = [])
  1084.     {
  1085.         if (isset($params['index'])) {
  1086.             $url '/' $this->encode($params['index']) . '/_mtermvectors';
  1087.             $method = empty($params['body']) ? 'GET' 'POST';
  1088.         } else {
  1089.             $url '/_mtermvectors';
  1090.             $method = empty($params['body']) ? 'GET' 'POST';
  1091.         }
  1092.         $url $this->addQueryString($url$params, ['ids','term_statistics','field_statistics','fields','offsets','positions','payloads','preference','routing','realtime','version','version_type','pretty','human','error_trace','source','filter_path']);
  1093.         $headers = [
  1094.             'Accept' => 'application/json',
  1095.             'Content-Type' => 'application/json',
  1096.         ];
  1097.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1098.     }
  1099.     /**
  1100.      * Open a point in time that can be used in subsequent searches
  1101.      *
  1102.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html
  1103.      *
  1104.      * @param array{
  1105.      *     index: list, // (REQUIRED) A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices
  1106.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  1107.      *     routing: string, // Specific routing value
  1108.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1109.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  1110.      *     keep_alive: string, // Specific the time to live for the point in time
  1111.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1112.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1113.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1114.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1115.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1116.      * } $params
  1117.      *
  1118.      * @throws MissingParameterException if a required parameter is missing
  1119.      * @throws NoNodeAvailableException if all the hosts are offline
  1120.      * @throws ClientResponseException if the status code of response is 4xx
  1121.      * @throws ServerResponseException if the status code of response is 5xx
  1122.      *
  1123.      * @return Elasticsearch|Promise
  1124.      */
  1125.     public function openPointInTime(array $params = [])
  1126.     {
  1127.         $this->checkRequiredParameters(['index','keep_alive'], $params);
  1128.         $url '/' $this->encode($params['index']) . '/_pit';
  1129.         $method 'POST';
  1130.         $url $this->addQueryString($url$params, ['preference','routing','ignore_unavailable','expand_wildcards','keep_alive','pretty','human','error_trace','source','filter_path']);
  1131.         $headers = [
  1132.             'Accept' => 'application/json',
  1133.         ];
  1134.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1135.     }
  1136.     /**
  1137.      * Returns whether the cluster is running.
  1138.      *
  1139.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
  1140.      *
  1141.      * @param array{
  1142.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1143.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1144.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1145.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1146.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1147.      * } $params
  1148.      *
  1149.      * @throws NoNodeAvailableException if all the hosts are offline
  1150.      * @throws ClientResponseException if the status code of response is 4xx
  1151.      * @throws ServerResponseException if the status code of response is 5xx
  1152.      *
  1153.      * @return Elasticsearch|Promise
  1154.      */
  1155.     public function ping(array $params = [])
  1156.     {
  1157.         $url '/';
  1158.         $method 'HEAD';
  1159.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  1160.         $headers = [
  1161.             'Accept' => 'application/json',
  1162.         ];
  1163.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1164.     }
  1165.     /**
  1166.      * Creates or updates a script.
  1167.      *
  1168.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
  1169.      *
  1170.      * @param array{
  1171.      *     id: string, // (REQUIRED) Script ID
  1172.      *     context: string, //  Script context
  1173.      *     timeout: time, // Explicit operation timeout
  1174.      *     master_timeout: time, // Specify timeout for connection to master
  1175.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1176.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1177.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1178.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1179.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1180.      *     body: array, // (REQUIRED) The document
  1181.      * } $params
  1182.      *
  1183.      * @throws MissingParameterException if a required parameter is missing
  1184.      * @throws NoNodeAvailableException if all the hosts are offline
  1185.      * @throws ClientResponseException if the status code of response is 4xx
  1186.      * @throws ServerResponseException if the status code of response is 5xx
  1187.      *
  1188.      * @return Elasticsearch|Promise
  1189.      */
  1190.     public function putScript(array $params = [])
  1191.     {
  1192.         $this->checkRequiredParameters(['id','body'], $params);
  1193.         if (isset($params['context'])) {
  1194.             $url '/_scripts/' $this->encode($params['id']) . '/' $this->encode($params['context']);
  1195.             $method 'PUT';
  1196.         } else {
  1197.             $url '/_scripts/' $this->encode($params['id']);
  1198.             $method 'PUT';
  1199.         }
  1200.         $url $this->addQueryString($url$params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
  1201.         $headers = [
  1202.             'Accept' => 'application/json',
  1203.             'Content-Type' => 'application/json',
  1204.         ];
  1205.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1206.     }
  1207.     /**
  1208.      * Allows to evaluate the quality of ranked search results over a set of typical search queries
  1209.      *
  1210.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html
  1211.      *
  1212.      * @param array{
  1213.      *     index: list, //  A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  1214.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1215.      *     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)
  1216.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  1217.      *     search_type: enum, // Search operation type
  1218.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1219.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1220.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1221.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1222.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1223.      *     body: array, // (REQUIRED) The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.
  1224.      * } $params
  1225.      *
  1226.      * @throws NoNodeAvailableException if all the hosts are offline
  1227.      * @throws ClientResponseException if the status code of response is 4xx
  1228.      * @throws ServerResponseException if the status code of response is 5xx
  1229.      *
  1230.      * @return Elasticsearch|Promise
  1231.      */
  1232.     public function rankEval(array $params = [])
  1233.     {
  1234.         $this->checkRequiredParameters(['body'], $params);
  1235.         if (isset($params['index'])) {
  1236.             $url '/' $this->encode($params['index']) . '/_rank_eval';
  1237.             $method = empty($params['body']) ? 'GET' 'POST';
  1238.         } else {
  1239.             $url '/_rank_eval';
  1240.             $method = empty($params['body']) ? 'GET' 'POST';
  1241.         }
  1242.         $url $this->addQueryString($url$params, ['ignore_unavailable','allow_no_indices','expand_wildcards','search_type','pretty','human','error_trace','source','filter_path']);
  1243.         $headers = [
  1244.             'Accept' => 'application/json',
  1245.             'Content-Type' => 'application/json',
  1246.         ];
  1247.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1248.     }
  1249.     /**
  1250.      * Allows to copy documents from one index to another, optionally filtering the source
  1251.      * documents by a query, changing the destination index settings, or fetching the
  1252.      * documents from a remote cluster.
  1253.      *
  1254.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html
  1255.      *
  1256.      * @param array{
  1257.      *     refresh: boolean, // Should the affected indexes be refreshed?
  1258.      *     timeout: time, // Time each individual bulk request should wait for shards that are unavailable.
  1259.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the reindex 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)
  1260.      *     wait_for_completion: boolean, // Should the request should block until the reindex is complete.
  1261.      *     requests_per_second: number, // The throttle to set on this request in sub-requests per second. -1 means no throttle.
  1262.      *     scroll: time, // Control how long to keep the search context alive
  1263.      *     slices: number|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`.
  1264.      *     max_docs: number, // Maximum number of documents to process (default: all documents)
  1265.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1266.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1267.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1268.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1269.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1270.      *     body: array, // (REQUIRED) The search definition using the Query DSL and the prototype for the index request.
  1271.      * } $params
  1272.      *
  1273.      * @throws NoNodeAvailableException if all the hosts are offline
  1274.      * @throws ClientResponseException if the status code of response is 4xx
  1275.      * @throws ServerResponseException if the status code of response is 5xx
  1276.      *
  1277.      * @return Elasticsearch|Promise
  1278.      */
  1279.     public function reindex(array $params = [])
  1280.     {
  1281.         $this->checkRequiredParameters(['body'], $params);
  1282.         $url '/_reindex';
  1283.         $method 'POST';
  1284.         $url $this->addQueryString($url$params, ['refresh','timeout','wait_for_active_shards','wait_for_completion','requests_per_second','scroll','slices','max_docs','pretty','human','error_trace','source','filter_path']);
  1285.         $headers = [
  1286.             'Accept' => 'application/json',
  1287.             'Content-Type' => 'application/json',
  1288.         ];
  1289.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1290.     }
  1291.     /**
  1292.      * Changes the number of requests per second for a particular Reindex operation.
  1293.      *
  1294.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html
  1295.      *
  1296.      * @param array{
  1297.      *     task_id: string, // (REQUIRED) The task id to rethrottle
  1298.      *     requests_per_second: number, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
  1299.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1300.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1301.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1302.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1303.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1304.      * } $params
  1305.      *
  1306.      * @throws MissingParameterException if a required parameter is missing
  1307.      * @throws NoNodeAvailableException if all the hosts are offline
  1308.      * @throws ClientResponseException if the status code of response is 4xx
  1309.      * @throws ServerResponseException if the status code of response is 5xx
  1310.      *
  1311.      * @return Elasticsearch|Promise
  1312.      */
  1313.     public function reindexRethrottle(array $params = [])
  1314.     {
  1315.         $this->checkRequiredParameters(['task_id','requests_per_second'], $params);
  1316.         $url '/_reindex/' $this->encode($params['task_id']) . '/_rethrottle';
  1317.         $method 'POST';
  1318.         $url $this->addQueryString($url$params, ['requests_per_second','pretty','human','error_trace','source','filter_path']);
  1319.         $headers = [
  1320.             'Accept' => 'application/json',
  1321.         ];
  1322.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1323.     }
  1324.     /**
  1325.      * Allows to use the Mustache language to pre-render a search definition.
  1326.      *
  1327.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/render-search-template-api.html
  1328.      *
  1329.      * @param array{
  1330.      *     id: string, //  The id of the stored search template
  1331.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1332.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1333.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1334.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1335.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1336.      *     body: array, //  The search definition template and its params
  1337.      * } $params
  1338.      *
  1339.      * @throws NoNodeAvailableException if all the hosts are offline
  1340.      * @throws ClientResponseException if the status code of response is 4xx
  1341.      * @throws ServerResponseException if the status code of response is 5xx
  1342.      *
  1343.      * @return Elasticsearch|Promise
  1344.      */
  1345.     public function renderSearchTemplate(array $params = [])
  1346.     {
  1347.         if (isset($params['id'])) {
  1348.             $url '/_render/template/' $this->encode($params['id']);
  1349.             $method = empty($params['body']) ? 'GET' 'POST';
  1350.         } else {
  1351.             $url '/_render/template';
  1352.             $method = empty($params['body']) ? 'GET' 'POST';
  1353.         }
  1354.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  1355.         $headers = [
  1356.             'Accept' => 'application/json',
  1357.             'Content-Type' => 'application/json',
  1358.         ];
  1359.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1360.     }
  1361.     /**
  1362.      * Allows an arbitrary script to be executed and a result to be returned
  1363.      *
  1364.      * @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html
  1365.      * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
  1366.      *
  1367.      * @param array{
  1368.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1369.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1370.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1371.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1372.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1373.      *     body: array, //  The script to execute
  1374.      * } $params
  1375.      *
  1376.      * @throws NoNodeAvailableException if all the hosts are offline
  1377.      * @throws ClientResponseException if the status code of response is 4xx
  1378.      * @throws ServerResponseException if the status code of response is 5xx
  1379.      *
  1380.      * @return Elasticsearch|Promise
  1381.      */
  1382.     public function scriptsPainlessExecute(array $params = [])
  1383.     {
  1384.         $url '/_scripts/painless/_execute';
  1385.         $method = empty($params['body']) ? 'GET' 'POST';
  1386.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  1387.         $headers = [
  1388.             'Accept' => 'application/json',
  1389.             'Content-Type' => 'application/json',
  1390.         ];
  1391.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1392.     }
  1393.     /**
  1394.      * Allows to retrieve a large numbers of results from a single search request.
  1395.      *
  1396.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll
  1397.      *
  1398.      * @param array{
  1399.      *     scroll_id: string, //  The scroll ID
  1400.      *     scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search
  1401.      *     rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  1402.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1403.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1404.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1405.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1406.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1407.      *     body: array, //  The scroll ID if not passed by URL or query parameter.
  1408.      * } $params
  1409.      *
  1410.      * @throws NoNodeAvailableException if all the hosts are offline
  1411.      * @throws ClientResponseException if the status code of response is 4xx
  1412.      * @throws ServerResponseException if the status code of response is 5xx
  1413.      *
  1414.      * @return Elasticsearch|Promise
  1415.      */
  1416.     public function scroll(array $params = [])
  1417.     {
  1418.         if (isset($params['scroll_id'])) {
  1419.             $url '/_search/scroll/' $this->encode($params['scroll_id']);
  1420.             $method = empty($params['body']) ? 'GET' 'POST';
  1421.         } else {
  1422.             $url '/_search/scroll';
  1423.             $method = empty($params['body']) ? 'GET' 'POST';
  1424.         }
  1425.         $url $this->addQueryString($url$params, ['scroll','rest_total_hits_as_int','pretty','human','error_trace','source','filter_path']);
  1426.         $headers = [
  1427.             'Accept' => 'application/json',
  1428.             'Content-Type' => 'application/json',
  1429.         ];
  1430.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1431.     }
  1432.     /**
  1433.      * Returns results matching a query.
  1434.      *
  1435.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html
  1436.      *
  1437.      * @param array{
  1438.      *     index: list, //  A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  1439.      *     analyzer: string, // The analyzer to use for the query string
  1440.      *     analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false)
  1441.      *     ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  1442.      *     default_operator: enum, // The default operator for query string query (AND or OR)
  1443.      *     df: string, // The field to use as default where no field prefix is given in the query string
  1444.      *     explain: boolean, // Specify whether to return detailed information about score computation as part of a hit
  1445.      *     stored_fields: list, // A comma-separated list of stored fields to return as part of a hit
  1446.      *     docvalue_fields: list, // A comma-separated list of fields to return as the docvalue representation of a field for each hit
  1447.      *     from: number, // Starting offset (default: 0)
  1448.      *     force_synthetic_source: boolean, // Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index.
  1449.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1450.      *     ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled
  1451.      *     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)
  1452.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  1453.      *     lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  1454.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  1455.      *     q: string, // Query in the Lucene query string syntax
  1456.      *     routing: list, // A comma-separated list of specific routing values
  1457.      *     scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search
  1458.      *     search_type: enum, // Search operation type
  1459.      *     size: number, // Number of hits to return (default: 10)
  1460.      *     sort: list, // A comma-separated list of <field>:<direction> pairs
  1461.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  1462.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  1463.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  1464.      *     terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  1465.      *     stats: list, // Specific 'tag' of the request for logging and statistical purposes
  1466.      *     suggest_field: string, // Specify which field to use for suggestions
  1467.      *     suggest_mode: enum, // Specify suggest mode
  1468.      *     suggest_size: number, // How many suggestions to return in response
  1469.      *     suggest_text: string, // The source text for which the suggestions should be returned
  1470.      *     timeout: time, // Explicit operation timeout
  1471.      *     track_scores: boolean, // Whether to calculate and return scores even if they are not used for sorting
  1472.      *     track_total_hits: boolean|long, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
  1473.      *     allow_partial_search_results: boolean, // Indicate if an error should be returned if there is a partial search failure or timeout
  1474.      *     typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  1475.      *     version: boolean, // Specify whether to return document version as part of a hit
  1476.      *     seq_no_primary_term: boolean, // Specify whether to return sequence number and primary term of the last modification of each hit
  1477.      *     request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to index level setting
  1478.      *     batched_reduce_size: number, // The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
  1479.      *     max_concurrent_shard_requests: number, // The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
  1480.      *     pre_filter_shard_size: number, // A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
  1481.      *     rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  1482.      *     min_compatible_shard_node: string, // The minimum compatible version that all shards involved in search should have for this request to be successful
  1483.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1484.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1485.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1486.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1487.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1488.      *     body: array, //  The search definition using the Query DSL
  1489.      * } $params
  1490.      *
  1491.      * @throws NoNodeAvailableException if all the hosts are offline
  1492.      * @throws ClientResponseException if the status code of response is 4xx
  1493.      * @throws ServerResponseException if the status code of response is 5xx
  1494.      *
  1495.      * @return Elasticsearch|Promise
  1496.      */
  1497.     public function search(array $params = [])
  1498.     {
  1499.         if (isset($params['index'])) {
  1500.             $url '/' $this->encode($params['index']) . '/_search';
  1501.             $method = empty($params['body']) ? 'GET' 'POST';
  1502.         } else {
  1503.             $url '/_search';
  1504.             $method = empty($params['body']) ? 'GET' 'POST';
  1505.         }
  1506.         $url $this->addQueryString($url$params, ['analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','force_synthetic_source','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','scroll','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','request_cache','batched_reduce_size','max_concurrent_shard_requests','pre_filter_shard_size','rest_total_hits_as_int','min_compatible_shard_node','pretty','human','error_trace','source','filter_path']);
  1507.         $headers = [
  1508.             'Accept' => 'application/json',
  1509.             'Content-Type' => 'application/json',
  1510.         ];
  1511.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1512.     }
  1513.     /**
  1514.      * Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.
  1515.      *
  1516.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html
  1517.      * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release
  1518.      *
  1519.      * @param array{
  1520.      *     index: list, // (REQUIRED) Comma-separated list of data streams, indices, or aliases to search
  1521.      *     field: string, // (REQUIRED) Field containing geospatial data to return
  1522.      *     zoom: int, // (REQUIRED) Zoom level for the vector tile to search
  1523.      *     x: int, // (REQUIRED) X coordinate for the vector tile to search
  1524.      *     y: int, // (REQUIRED) Y coordinate for the vector tile to search
  1525.      *     exact_bounds: boolean, // If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation.
  1526.      *     extent: int, // Size, in pixels, of a side of the vector tile.
  1527.      *     grid_precision: int, // Additional zoom levels available through the aggs layer. Accepts 0-8.
  1528.      *     grid_type: enum, // Determines the geometry type for features in the aggs layer.
  1529.      *     size: int, // Maximum number of features to return in the hits layer. Accepts 0-10000.
  1530.      *     track_total_hits: boolean|long, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
  1531.      *     with_labels: boolean, // If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features.
  1532.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1533.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1534.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1535.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1536.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1537.      *     body: array, //  Search request body.
  1538.      * } $params
  1539.      *
  1540.      * @throws MissingParameterException if a required parameter is missing
  1541.      * @throws NoNodeAvailableException if all the hosts are offline
  1542.      * @throws ClientResponseException if the status code of response is 4xx
  1543.      * @throws ServerResponseException if the status code of response is 5xx
  1544.      *
  1545.      * @return Elasticsearch|Promise
  1546.      */
  1547.     public function searchMvt(array $params = [])
  1548.     {
  1549.         $this->checkRequiredParameters(['index','field','zoom','x','y'], $params);
  1550.         $url '/' $this->encode($params['index']) . '/_mvt/' $this->encode($params['field']) . '/' $this->encode($params['zoom']) . '/' $this->encode($params['x']) . '/' $this->encode($params['y']);
  1551.         $method = empty($params['body']) ? 'GET' 'POST';
  1552.         $url $this->addQueryString($url$params, ['exact_bounds','extent','grid_precision','grid_type','size','track_total_hits','with_labels','pretty','human','error_trace','source','filter_path']);
  1553.         $headers = [
  1554.             'Accept' => 'application/vnd.mapbox-vector-tile',
  1555.             'Content-Type' => 'application/json',
  1556.         ];
  1557.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1558.     }
  1559.     /**
  1560.      * Returns information about the indices and shards that a search request would be executed against.
  1561.      *
  1562.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html
  1563.      *
  1564.      * @param array{
  1565.      *     index: list, //  A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  1566.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  1567.      *     routing: string, // Specific routing value
  1568.      *     local: boolean, // Return local information, do not retrieve the state from master node (default: false)
  1569.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1570.      *     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)
  1571.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  1572.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1573.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1574.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1575.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1576.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1577.      * } $params
  1578.      *
  1579.      * @throws NoNodeAvailableException if all the hosts are offline
  1580.      * @throws ClientResponseException if the status code of response is 4xx
  1581.      * @throws ServerResponseException if the status code of response is 5xx
  1582.      *
  1583.      * @return Elasticsearch|Promise
  1584.      */
  1585.     public function searchShards(array $params = [])
  1586.     {
  1587.         if (isset($params['index'])) {
  1588.             $url '/' $this->encode($params['index']) . '/_search_shards';
  1589.             $method = empty($params['body']) ? 'GET' 'POST';
  1590.         } else {
  1591.             $url '/_search_shards';
  1592.             $method = empty($params['body']) ? 'GET' 'POST';
  1593.         }
  1594.         $url $this->addQueryString($url$params, ['preference','routing','local','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']);
  1595.         $headers = [
  1596.             'Accept' => 'application/json',
  1597.         ];
  1598.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1599.     }
  1600.     /**
  1601.      * Allows to use the Mustache language to pre-render a search definition.
  1602.      *
  1603.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
  1604.      *
  1605.      * @param array{
  1606.      *     index: list, //  A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  1607.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1608.      *     ignore_throttled: boolean, // Whether specified concrete, expanded or aliased indices should be ignored when throttled
  1609.      *     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)
  1610.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  1611.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  1612.      *     routing: list, // A comma-separated list of specific routing values
  1613.      *     scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search
  1614.      *     search_type: enum, // Search operation type
  1615.      *     explain: boolean, // Specify whether to return detailed information about score computation as part of a hit
  1616.      *     profile: boolean, // Specify whether to profile the query execution
  1617.      *     typed_keys: boolean, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  1618.      *     rest_total_hits_as_int: boolean, // Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  1619.      *     ccs_minimize_roundtrips: boolean, // Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  1620.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1621.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1622.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1623.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1624.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1625.      *     body: array, // (REQUIRED) The search definition template and its params
  1626.      * } $params
  1627.      *
  1628.      * @throws NoNodeAvailableException if all the hosts are offline
  1629.      * @throws ClientResponseException if the status code of response is 4xx
  1630.      * @throws ServerResponseException if the status code of response is 5xx
  1631.      *
  1632.      * @return Elasticsearch|Promise
  1633.      */
  1634.     public function searchTemplate(array $params = [])
  1635.     {
  1636.         $this->checkRequiredParameters(['body'], $params);
  1637.         if (isset($params['index'])) {
  1638.             $url '/' $this->encode($params['index']) . '/_search/template';
  1639.             $method = empty($params['body']) ? 'GET' 'POST';
  1640.         } else {
  1641.             $url '/_search/template';
  1642.             $method = empty($params['body']) ? 'GET' 'POST';
  1643.         }
  1644.         $url $this->addQueryString($url$params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','preference','routing','scroll','search_type','explain','profile','typed_keys','rest_total_hits_as_int','ccs_minimize_roundtrips','pretty','human','error_trace','source','filter_path']);
  1645.         $headers = [
  1646.             'Accept' => 'application/json',
  1647.             'Content-Type' => 'application/json',
  1648.         ];
  1649.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1650.     }
  1651.     /**
  1652.      * The terms enum API  can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.
  1653.      *
  1654.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html
  1655.      *
  1656.      * @param array{
  1657.      *     index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  1658.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1659.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1660.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1661.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1662.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1663.      *     body: array, //  field name, string which is the prefix expected in matching terms, timeout and size for max number of results
  1664.      * } $params
  1665.      *
  1666.      * @throws MissingParameterException if a required parameter is missing
  1667.      * @throws NoNodeAvailableException if all the hosts are offline
  1668.      * @throws ClientResponseException if the status code of response is 4xx
  1669.      * @throws ServerResponseException if the status code of response is 5xx
  1670.      *
  1671.      * @return Elasticsearch|Promise
  1672.      */
  1673.     public function termsEnum(array $params = [])
  1674.     {
  1675.         $this->checkRequiredParameters(['index'], $params);
  1676.         $url '/' $this->encode($params['index']) . '/_terms_enum';
  1677.         $method = empty($params['body']) ? 'GET' 'POST';
  1678.         $url $this->addQueryString($url$params, ['pretty','human','error_trace','source','filter_path']);
  1679.         $headers = [
  1680.             'Accept' => 'application/json',
  1681.             'Content-Type' => 'application/json',
  1682.         ];
  1683.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1684.     }
  1685.     /**
  1686.      * Returns information and statistics about terms in the fields of a particular document.
  1687.      *
  1688.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html
  1689.      *
  1690.      * @param array{
  1691.      *     index: string, // (REQUIRED) The index in which the document resides.
  1692.      *     id: string, //  The id of the document, when not specified a doc param should be supplied.
  1693.      *     term_statistics: boolean, // Specifies if total term frequency and document frequency should be returned.
  1694.      *     field_statistics: boolean, // Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.
  1695.      *     fields: list, // A comma-separated list of fields to return.
  1696.      *     offsets: boolean, // Specifies if term offsets should be returned.
  1697.      *     positions: boolean, // Specifies if term positions should be returned.
  1698.      *     payloads: boolean, // Specifies if term payloads should be returned.
  1699.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random).
  1700.      *     routing: string, // Specific routing value.
  1701.      *     realtime: boolean, // Specifies if request is real-time as opposed to near-real-time (default: true).
  1702.      *     version: number, // Explicit version number for concurrency control
  1703.      *     version_type: enum, // Specific version type
  1704.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1705.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1706.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1707.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1708.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1709.      *     body: array, //  Define parameters and or supply a document to get termvectors for. See documentation.
  1710.      * } $params
  1711.      *
  1712.      * @throws MissingParameterException if a required parameter is missing
  1713.      * @throws NoNodeAvailableException if all the hosts are offline
  1714.      * @throws ClientResponseException if the status code of response is 4xx
  1715.      * @throws ServerResponseException if the status code of response is 5xx
  1716.      *
  1717.      * @return Elasticsearch|Promise
  1718.      */
  1719.     public function termvectors(array $params = [])
  1720.     {
  1721.         $this->checkRequiredParameters(['index'], $params);
  1722.         if (isset($params['id'])) {
  1723.             $url '/' $this->encode($params['index']) . '/_termvectors/' $this->encode($params['id']);
  1724.             $method = empty($params['body']) ? 'GET' 'POST';
  1725.         } else {
  1726.             $url '/' $this->encode($params['index']) . '/_termvectors';
  1727.             $method = empty($params['body']) ? 'GET' 'POST';
  1728.         }
  1729.         $url $this->addQueryString($url$params, ['term_statistics','field_statistics','fields','offsets','positions','payloads','preference','routing','realtime','version','version_type','pretty','human','error_trace','source','filter_path']);
  1730.         $headers = [
  1731.             'Accept' => 'application/json',
  1732.             'Content-Type' => 'application/json',
  1733.         ];
  1734.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1735.     }
  1736.     /**
  1737.      * Updates a document with a script or partial document.
  1738.      *
  1739.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html
  1740.      *
  1741.      * @param array{
  1742.      *     id: string, // (REQUIRED) Document ID
  1743.      *     index: string, // (REQUIRED) The name of the index
  1744.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the update 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)
  1745.      *     _source: list, // True or false to return the _source field or not, or a list of fields to return
  1746.      *     _source_excludes: list, // A list of fields to exclude from the returned _source field
  1747.      *     _source_includes: list, // A list of fields to extract and return from the _source field
  1748.      *     lang: string, // The script language (default: painless)
  1749.      *     refresh: enum, // If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
  1750.      *     retry_on_conflict: number, // Specify how many times should the operation be retried when a conflict occurs (default: 0)
  1751.      *     routing: string, // Specific routing value
  1752.      *     timeout: time, // Explicit operation timeout
  1753.      *     if_seq_no: number, // only perform the update operation if the last operation that has changed the document has the specified sequence number
  1754.      *     if_primary_term: number, // only perform the update operation if the last operation that has changed the document has the specified primary term
  1755.      *     require_alias: boolean, // When true, requires destination is an alias. Default is false
  1756.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1757.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1758.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1759.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1760.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1761.      *     body: array, // (REQUIRED) The request definition requires either `script` or partial `doc`
  1762.      * } $params
  1763.      *
  1764.      * @throws MissingParameterException if a required parameter is missing
  1765.      * @throws NoNodeAvailableException if all the hosts are offline
  1766.      * @throws ClientResponseException if the status code of response is 4xx
  1767.      * @throws ServerResponseException if the status code of response is 5xx
  1768.      *
  1769.      * @return Elasticsearch|Promise
  1770.      */
  1771.     public function update(array $params = [])
  1772.     {
  1773.         $this->checkRequiredParameters(['id','index','body'], $params);
  1774.         $url '/' $this->encode($params['index']) . '/_update/' $this->encode($params['id']);
  1775.         $method 'POST';
  1776.         $url $this->addQueryString($url$params, ['wait_for_active_shards','_source','_source_excludes','_source_includes','lang','refresh','retry_on_conflict','routing','timeout','if_seq_no','if_primary_term','require_alias','pretty','human','error_trace','source','filter_path']);
  1777.         $headers = [
  1778.             'Accept' => 'application/json',
  1779.             'Content-Type' => 'application/json',
  1780.         ];
  1781.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1782.     }
  1783.     /**
  1784.      * Performs an update on every document in the index without changing the source,
  1785.      * for example to pick up a mapping change.
  1786.      *
  1787.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html
  1788.      *
  1789.      * @param array{
  1790.      *     index: list, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
  1791.      *     analyzer: string, // The analyzer to use for the query string
  1792.      *     analyze_wildcard: boolean, // Specify whether wildcard and prefix queries should be analyzed (default: false)
  1793.      *     default_operator: enum, // The default operator for query string query (AND or OR)
  1794.      *     df: string, // The field to use as default where no field prefix is given in the query string
  1795.      *     from: number, // Starting offset (default: 0)
  1796.      *     ignore_unavailable: boolean, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1797.      *     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)
  1798.      *     conflicts: enum, // What to do when the update by query hits version conflicts?
  1799.      *     expand_wildcards: enum, // Whether to expand wildcard expression to concrete indices that are open, closed or both.
  1800.      *     lenient: boolean, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  1801.      *     pipeline: string, // Ingest pipeline to set on index requests made by this action. (default: none)
  1802.      *     preference: string, // Specify the node or shard the operation should be performed on (default: random)
  1803.      *     q: string, // Query in the Lucene query string syntax
  1804.      *     routing: list, // A comma-separated list of specific routing values
  1805.      *     scroll: time, // Specify how long a consistent view of the index should be maintained for scrolled search
  1806.      *     search_type: enum, // Search operation type
  1807.      *     search_timeout: time, // Explicit timeout for each search request. Defaults to no timeout.
  1808.      *     max_docs: number, // Maximum number of documents to process (default: all documents)
  1809.      *     sort: list, // A comma-separated list of <field>:<direction> pairs
  1810.      *     terminate_after: number, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  1811.      *     stats: list, // Specific 'tag' of the request for logging and statistical purposes
  1812.      *     version: boolean, // Specify whether to return document version as part of a hit
  1813.      *     version_type: boolean, // Should the document increment the version number (internal) on hit or not (reindex)
  1814.      *     request_cache: boolean, // Specify if request cache should be used for this request or not, defaults to index level setting
  1815.      *     refresh: boolean, // Should the affected indexes be refreshed?
  1816.      *     timeout: time, // Time each individual bulk request should wait for shards that are unavailable.
  1817.      *     wait_for_active_shards: string, // Sets the number of shard copies that must be active before proceeding with the update 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)
  1818.      *     scroll_size: number, // Size on the scroll request powering the update by query
  1819.      *     wait_for_completion: boolean, // Should the request should block until the update by query operation is complete.
  1820.      *     requests_per_second: number, // The throttle to set on this request in sub-requests per second. -1 means no throttle.
  1821.      *     slices: number|string, // The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`.
  1822.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1823.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1824.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1825.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1826.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1827.      *     body: array, //  The search definition using the Query DSL
  1828.      * } $params
  1829.      *
  1830.      * @throws MissingParameterException if a required parameter is missing
  1831.      * @throws NoNodeAvailableException if all the hosts are offline
  1832.      * @throws ClientResponseException if the status code of response is 4xx
  1833.      * @throws ServerResponseException if the status code of response is 5xx
  1834.      *
  1835.      * @return Elasticsearch|Promise
  1836.      */
  1837.     public function updateByQuery(array $params = [])
  1838.     {
  1839.         $this->checkRequiredParameters(['index'], $params);
  1840.         $url '/' $this->encode($params['index']) . '/_update_by_query';
  1841.         $method 'POST';
  1842.         $url $this->addQueryString($url$params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','pipeline','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','version_type','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']);
  1843.         $headers = [
  1844.             'Accept' => 'application/json',
  1845.             'Content-Type' => 'application/json',
  1846.         ];
  1847.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1848.     }
  1849.     /**
  1850.      * Changes the number of requests per second for a particular Update By Query operation.
  1851.      *
  1852.      * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
  1853.      *
  1854.      * @param array{
  1855.      *     task_id: string, // (REQUIRED) The task id to rethrottle
  1856.      *     requests_per_second: number, // The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
  1857.      *     pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false)
  1858.      *     human: boolean, // Return human readable values for statistics. (DEFAULT: true)
  1859.      *     error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false)
  1860.      *     source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
  1861.      *     filter_path: list, // A comma-separated list of filters used to reduce the response.
  1862.      * } $params
  1863.      *
  1864.      * @throws MissingParameterException if a required parameter is missing
  1865.      * @throws NoNodeAvailableException if all the hosts are offline
  1866.      * @throws ClientResponseException if the status code of response is 4xx
  1867.      * @throws ServerResponseException if the status code of response is 5xx
  1868.      *
  1869.      * @return Elasticsearch|Promise
  1870.      */
  1871.     public function updateByQueryRethrottle(array $params = [])
  1872.     {
  1873.         $this->checkRequiredParameters(['task_id','requests_per_second'], $params);
  1874.         $url '/_update_by_query/' $this->encode($params['task_id']) . '/_rethrottle';
  1875.         $method 'POST';
  1876.         $url $this->addQueryString($url$params, ['requests_per_second','pretty','human','error_trace','source','filter_path']);
  1877.         $headers = [
  1878.             'Accept' => 'application/json',
  1879.         ];
  1880.         return $this->sendRequest($this->createRequest($method$url$headers$params['body'] ?? null));
  1881.     }
  1882. }