1<?php
2/**
3 * Elasticsearch PHP client
4 *
5 * @link      https://github.com/elastic/elasticsearch-php/
6 * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
7 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8 * @license   https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
9 *
10 * Licensed to Elasticsearch B.V under one or more agreements.
11 * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
12 * the GNU Lesser General Public License, Version 2.1, at your option.
13 * See the LICENSE file in the project root for more information.
14 */
15declare(strict_types = 1);
16
17namespace Elasticsearch\Endpoints;
18
19use Elasticsearch\Endpoints\AbstractEndpoint;
20
21/**
22 * Class Search
23 * Elasticsearch API name search
24 *
25 * NOTE: this file is autogenerated using util/GenerateEndpoints.php
26 * and Elasticsearch 7.16.0-SNAPSHOT (dfc9a8e7563ed5f24b5210ed21ed92ae182cd0ee)
27 */
28class Search extends AbstractEndpoint
29{
30
31    public function getURI(): string
32    {
33        $index = $this->index ?? null;
34        $type = $this->type ?? null;
35        if (isset($type)) {
36            @trigger_error('Specifying types in urls has been deprecated', E_USER_DEPRECATED);
37        }
38
39        if (isset($index) && isset($type)) {
40            return "/$index/$type/_search";
41        }
42        if (isset($index)) {
43            return "/$index/_search";
44        }
45        return "/_search";
46    }
47
48    public function getParamWhitelist(): array
49    {
50        return [
51            'analyzer',
52            'analyze_wildcard',
53            'ccs_minimize_roundtrips',
54            'default_operator',
55            'df',
56            'explain',
57            'stored_fields',
58            'docvalue_fields',
59            'from',
60            'ignore_unavailable',
61            'ignore_throttled',
62            'allow_no_indices',
63            'expand_wildcards',
64            'lenient',
65            'preference',
66            'q',
67            'routing',
68            'scroll',
69            'search_type',
70            'size',
71            'sort',
72            '_source',
73            '_source_excludes',
74            '_source_includes',
75            'terminate_after',
76            'stats',
77            'suggest_field',
78            'suggest_mode',
79            'suggest_size',
80            'suggest_text',
81            'timeout',
82            'track_scores',
83            'track_total_hits',
84            'allow_partial_search_results',
85            'typed_keys',
86            'version',
87            'seq_no_primary_term',
88            'request_cache',
89            'batched_reduce_size',
90            'max_concurrent_shard_requests',
91            'pre_filter_shard_size',
92            'rest_total_hits_as_int',
93            'min_compatible_shard_node'
94        ];
95    }
96
97    public function getMethod(): string
98    {
99        return isset($this->body) ? 'POST' : 'GET';
100    }
101
102    public function setBody($body): Search
103    {
104        if (isset($body) !== true) {
105            return $this;
106        }
107        $this->body = $body;
108
109        return $this;
110    }
111}
112