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