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