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 Count extends AbstractEndpoint |
28: | { |
29: | public function getURI(): string |
30: | { |
31: | $index = $this->index ?? null; |
32: | if (isset($index)) { |
33: | return "/$index/_count"; |
34: | } |
35: | return "/_count"; |
36: | } |
37: | |
38: | public function getParamWhitelist(): array |
39: | { |
40: | return [ |
41: | 'allow_no_indices', |
42: | 'analyze_wildcard', |
43: | 'analyzer', |
44: | 'default_operator', |
45: | 'df', |
46: | 'expand_wildcards', |
47: | 'ignore_throttled', |
48: | 'ignore_unavailable', |
49: | 'lenient', |
50: | 'min_score', |
51: | 'preference', |
52: | 'q', |
53: | 'routing', |
54: | 'terminate_after', |
55: | 'pretty', |
56: | 'human', |
57: | 'error_trace', |
58: | 'source', |
59: | 'filter_path' |
60: | ]; |
61: | } |
62: | |
63: | public function getMethod(): string |
64: | { |
65: | return isset($this->body) ? 'POST' : 'GET'; |
66: | } |
67: | |
68: | public function setBody($body): static |
69: | { |
70: | if (is_null($body)) { |
71: | return $this; |
72: | } |
73: | $this->body = $body; |
74: | |
75: | return $this; |
76: | } |
77: | } |
78: | |