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: | use OpenSearch\Endpoints\AbstractEndpoint; |
25: | |
26: | |
27: | |
28: | |
29: | class SearchTemplate extends AbstractEndpoint |
30: | { |
31: | public function getURI(): string |
32: | { |
33: | $index = $this->index ?? null; |
34: | if (isset($index)) { |
35: | return "/$index/_search/template"; |
36: | } |
37: | return "/_search/template"; |
38: | } |
39: | |
40: | public function getParamWhitelist(): array |
41: | { |
42: | return [ |
43: | 'allow_no_indices', |
44: | 'ccs_minimize_roundtrips', |
45: | 'expand_wildcards', |
46: | 'explain', |
47: | 'ignore_throttled', |
48: | 'ignore_unavailable', |
49: | 'preference', |
50: | 'profile', |
51: | 'rest_total_hits_as_int', |
52: | 'routing', |
53: | 'scroll', |
54: | 'search_type', |
55: | 'typed_keys', |
56: | 'pretty', |
57: | 'human', |
58: | 'error_trace', |
59: | 'source', |
60: | 'filter_path' |
61: | ]; |
62: | } |
63: | |
64: | public function getMethod(): string |
65: | { |
66: | return isset($this->body) ? 'POST' : 'GET'; |
67: | } |
68: | |
69: | public function setBody($body): static |
70: | { |
71: | if (isset($body) !== true) { |
72: | return $this; |
73: | } |
74: | $this->body = $body; |
75: | |
76: | return $this; |
77: | } |
78: | } |
79: | |