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   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8 * @license   https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
9 *
10 * Licensed to Elasticsearch B.V under one or more agreements.
11 * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
12 * the GNU Lesser General Public License, Version 2.1, at your option.
13 * See the LICENSE file in the project root for more information.
14 */
15declare(strict_types = 1);
16
17namespace Elasticsearch\Namespaces;
18
19use Elasticsearch\Namespaces\AbstractNamespace;
20
21/**
22 * Class AsyncSearchNamespace
23 *
24 * NOTE: this file is autogenerated using util/GenerateEndpoints.php
25 * and Elasticsearch 7.16.0-SNAPSHOT (dfc9a8e7563ed5f24b5210ed21ed92ae182cd0ee)
26 */
27class AsyncSearchNamespace extends AbstractNamespace
28{
29
30    /**
31     * Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
32     *
33     * $params['id'] = (string) The async search ID
34     *
35     * @param array $params Associative array of parameters
36     * @return array
37     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
38     */
39    public function delete(array $params = [])
40    {
41        $id = $this->extractArgument($params, 'id');
42
43        $endpointBuilder = $this->endpoints;
44        $endpoint = $endpointBuilder('AsyncSearch\Delete');
45        $endpoint->setParams($params);
46        $endpoint->setId($id);
47
48        return $this->performRequest($endpoint);
49    }
50    /**
51     * Retrieves the results of a previously submitted async search request given its ID.
52     *
53     * $params['id']                          = (string) The async search ID
54     * $params['wait_for_completion_timeout'] = (time) Specify the time that the request should block waiting for the final response
55     * $params['keep_alive']                  = (time) Specify the time interval in which the results (partial or final) for this search will be available
56     * $params['typed_keys']                  = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response
57     *
58     * @param array $params Associative array of parameters
59     * @return array
60     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
61     */
62    public function get(array $params = [])
63    {
64        $id = $this->extractArgument($params, 'id');
65
66        $endpointBuilder = $this->endpoints;
67        $endpoint = $endpointBuilder('AsyncSearch\Get');
68        $endpoint->setParams($params);
69        $endpoint->setId($id);
70
71        return $this->performRequest($endpoint);
72    }
73    /**
74     * Retrieves the status of a previously submitted async search request given its ID.
75     *
76     * $params['id'] = (string) The async search ID
77     *
78     * @param array $params Associative array of parameters
79     * @return array
80     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
81     */
82    public function status(array $params = [])
83    {
84        $id = $this->extractArgument($params, 'id');
85
86        $endpointBuilder = $this->endpoints;
87        $endpoint = $endpointBuilder('AsyncSearch\Status');
88        $endpoint->setParams($params);
89        $endpoint->setId($id);
90
91        return $this->performRequest($endpoint);
92    }
93    /**
94     * Executes a search request asynchronously.
95     *
96     * $params['index']                         = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
97     * $params['wait_for_completion_timeout']   = (time) Specify the time that the request should block waiting for the final response (Default = 1s)
98     * $params['keep_on_completion']            = (boolean) Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) (Default = false)
99     * $params['keep_alive']                    = (time) Update the time interval in which the results (partial or final) for this search will be available (Default = 5d)
100     * $params['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 the granularity at which progress results will be made available. (Default = 5)
101     * $params['request_cache']                 = (boolean) Specify if request cache should be used for this request or not, defaults to true
102     * $params['analyzer']                      = (string) The analyzer to use for the query string
103     * $params['analyze_wildcard']              = (boolean) Specify whether wildcard and prefix queries should be analyzed (default: false)
104     * $params['default_operator']              = (enum) The default operator for query string query (AND or OR) (Options = AND,OR) (Default = OR)
105     * $params['df']                            = (string) The field to use as default where no field prefix is given in the query string
106     * $params['explain']                       = (boolean) Specify whether to return detailed information about score computation as part of a hit
107     * $params['stored_fields']                 = (list) A comma-separated list of stored fields to return as part of a hit
108     * $params['docvalue_fields']               = (list) A comma-separated list of fields to return as the docvalue representation of a field for each hit
109     * $params['from']                          = (number) Starting offset (default: 0)
110     * $params['ignore_unavailable']            = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
111     * $params['ignore_throttled']              = (boolean) Whether specified concrete, expanded or aliased indices should be ignored when throttled
112     * $params['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)
113     * $params['expand_wildcards']              = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
114     * $params['lenient']                       = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
115     * $params['preference']                    = (string) Specify the node or shard the operation should be performed on (default: random)
116     * $params['q']                             = (string) Query in the Lucene query string syntax
117     * $params['routing']                       = (list) A comma-separated list of specific routing values
118     * $params['search_type']                   = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
119     * $params['size']                          = (number) Number of hits to return (default: 10)
120     * $params['sort']                          = (list) A comma-separated list of <field>:<direction> pairs
121     * $params['_source']                       = (list) True or false to return the _source field or not, or a list of fields to return
122     * $params['_source_excludes']              = (list) A list of fields to exclude from the returned _source field
123     * $params['_source_includes']              = (list) A list of fields to extract and return from the _source field
124     * $params['terminate_after']               = (number) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
125     * $params['stats']                         = (list) Specific 'tag' of the request for logging and statistical purposes
126     * $params['suggest_field']                 = (string) Specify which field to use for suggestions
127     * $params['suggest_mode']                  = (enum) Specify suggest mode (Options = missing,popular,always) (Default = missing)
128     * $params['suggest_size']                  = (number) How many suggestions to return in response
129     * $params['suggest_text']                  = (string) The source text for which the suggestions should be returned
130     * $params['timeout']                       = (time) Explicit operation timeout
131     * $params['track_scores']                  = (boolean) Whether to calculate and return scores even if they are not used for sorting
132     * $params['track_total_hits']              = (boolean) Indicate if the number of documents that match the query should be tracked
133     * $params['allow_partial_search_results']  = (boolean) Indicate if an error should be returned if there is a partial search failure or timeout (Default = true)
134     * $params['typed_keys']                    = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response
135     * $params['version']                       = (boolean) Specify whether to return document version as part of a hit
136     * $params['seq_no_primary_term']           = (boolean) Specify whether to return sequence number and primary term of the last modification of each hit
137     * $params['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 (Default = 5)
138     * $params['body']                          = (array) The search definition using the Query DSL
139     *
140     * @param array $params Associative array of parameters
141     * @return array
142     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html
143     */
144    public function submit(array $params = [])
145    {
146        $index = $this->extractArgument($params, 'index');
147        $body = $this->extractArgument($params, 'body');
148
149        $endpointBuilder = $this->endpoints;
150        $endpoint = $endpointBuilder('AsyncSearch\Submit');
151        $endpoint->setParams($params);
152        $endpoint->setIndex($index);
153        $endpoint->setBody($body);
154
155        return $this->performRequest($endpoint);
156    }
157}
158