1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: | |
18: | |
19: | |
20: | |
21: | |
22: | namespace OpenSearch\Endpoints; |
23: | |
24: | |
25: | |
26: | |
27: | class SearchTemplate extends AbstractEndpoint |
28: | { |
29: | public function getURI(): string |
30: | { |
31: | $index = $this->index ?? null; |
32: | if (isset($index)) { |
33: | return "/$index/_search/template"; |
34: | } |
35: | return "/_search/template"; |
36: | } |
37: | |
38: | public function getParamWhitelist(): array |
39: | { |
40: | return [ |
41: | 'allow_no_indices', |
42: | 'ccs_minimize_roundtrips', |
43: | 'expand_wildcards', |
44: | 'explain', |
45: | 'ignore_throttled', |
46: | 'ignore_unavailable', |
47: | 'preference', |
48: | 'profile', |
49: | 'rest_total_hits_as_int', |
50: | 'routing', |
51: | 'scroll', |
52: | 'search_type', |
53: | 'typed_keys', |
54: | 'pretty', |
55: | 'human', |
56: | 'error_trace', |
57: | 'source', |
58: | 'filter_path' |
59: | ]; |
60: | } |
61: | |
62: | public function getMethod(): string |
63: | { |
64: | return isset($this->body) ? 'POST' : 'GET'; |
65: | } |
66: | |
67: | public function setBody($body): static |
68: | { |
69: | if (is_null($body)) { |
70: | return $this; |
71: | } |
72: | $this->body = $body; |
73: | |
74: | return $this; |
75: | } |
76: | } |
77: | |