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 Search extends AbstractEndpoint |
30: | { |
31: | public function getURI(): string |
32: | { |
33: | $index = $this->index ?? null; |
34: | if (isset($index)) { |
35: | return "/$index/_search"; |
36: | } |
37: | return "/_search"; |
38: | } |
39: | |
40: | public function getParamWhitelist(): array |
41: | { |
42: | return [ |
43: | '_source', |
44: | '_source_excludes', |
45: | '_source_includes', |
46: | 'allow_no_indices', |
47: | 'allow_partial_search_results', |
48: | 'analyze_wildcard', |
49: | 'analyzer', |
50: | 'batched_reduce_size', |
51: | 'cancel_after_time_interval', |
52: | 'ccs_minimize_roundtrips', |
53: | 'default_operator', |
54: | 'df', |
55: | 'docvalue_fields', |
56: | 'expand_wildcards', |
57: | 'explain', |
58: | 'from', |
59: | 'ignore_throttled', |
60: | 'ignore_unavailable', |
61: | 'include_named_queries_score', |
62: | 'lenient', |
63: | 'max_concurrent_shard_requests', |
64: | 'phase_took', |
65: | 'pre_filter_shard_size', |
66: | 'preference', |
67: | 'q', |
68: | 'request_cache', |
69: | 'rest_total_hits_as_int', |
70: | 'routing', |
71: | 'scroll', |
72: | 'search_pipeline', |
73: | 'search_type', |
74: | 'seq_no_primary_term', |
75: | 'size', |
76: | 'sort', |
77: | 'stats', |
78: | 'stored_fields', |
79: | 'suggest_field', |
80: | 'suggest_mode', |
81: | 'suggest_size', |
82: | 'suggest_text', |
83: | 'terminate_after', |
84: | 'timeout', |
85: | 'track_scores', |
86: | 'track_total_hits', |
87: | 'typed_keys', |
88: | 'version', |
89: | 'pretty', |
90: | 'human', |
91: | 'error_trace', |
92: | 'source', |
93: | 'filter_path' |
94: | ]; |
95: | } |
96: | |
97: | public function getMethod(): string |
98: | { |
99: | return isset($this->body) ? 'POST' : 'GET'; |
100: | } |
101: | |
102: | public function setBody($body): static |
103: | { |
104: | if (isset($body) !== true) { |
105: | return $this; |
106: | } |
107: | $this->body = $body; |
108: | |
109: | return $this; |
110: | } |
111: | } |
112: | |