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\Endpoints\AsyncSearch;
23:
24: use OpenSearch\Endpoints\AbstractEndpoint;
25:
26: class Submit extends AbstractEndpoint
27: {
28: public function getURI(): string
29: {
30: $index = $this->index ?? null;
31:
32: if (isset($index)) {
33: return "/$index/_async_search";
34: }
35: return "/_async_search";
36: }
37:
38: public function getParamWhitelist(): array
39: {
40: return [
41: 'wait_for_completion_timeout',
42: 'keep_on_completion',
43: 'keep_alive',
44: 'batched_reduce_size',
45: 'request_cache',
46: 'analyzer',
47: 'analyze_wildcard',
48: 'default_operator',
49: 'df',
50: 'explain',
51: 'stored_fields',
52: 'docvalue_fields',
53: 'from',
54: 'ignore_unavailable',
55: 'ignore_throttled',
56: 'allow_no_indices',
57: 'expand_wildcards',
58: 'lenient',
59: 'preference',
60: 'q',
61: 'routing',
62: 'search_type',
63: 'size',
64: 'sort',
65: '_source',
66: '_source_excludes',
67: '_source_includes',
68: 'terminate_after',
69: 'stats',
70: 'suggest_field',
71: 'suggest_mode',
72: 'suggest_size',
73: 'suggest_text',
74: 'timeout',
75: 'track_scores',
76: 'track_total_hits',
77: 'allow_partial_search_results',
78: 'typed_keys',
79: 'version',
80: 'seq_no_primary_term',
81: 'max_concurrent_shard_requests'
82: ];
83: }
84:
85: public function getMethod(): string
86: {
87: return 'POST';
88: }
89:
90: public function setBody($body): Submit
91: {
92: if (isset($body) !== true) {
93: return $this;
94: }
95: $this->body = $body;
96:
97: return $this;
98: }
99: }
100: