1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Manticoresearch; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Manticoresearch\Endpoints\Indices\Alter; |
8
|
|
|
use Manticoresearch\Endpoints\Indices\Create; |
9
|
|
|
use Manticoresearch\Endpoints\Indices\Describe; |
10
|
|
|
use Manticoresearch\Endpoints\Indices\Drop; |
11
|
|
|
use Manticoresearch\Endpoints\Indices\FlushRamchunk; |
12
|
|
|
use Manticoresearch\Endpoints\Indices\FlushRtindex; |
13
|
|
|
use Manticoresearch\Endpoints\Indices\Import; |
14
|
|
|
use Manticoresearch\Endpoints\Indices\Optimize; |
15
|
|
|
use Manticoresearch\Endpoints\Indices\Settings; |
16
|
|
|
use Manticoresearch\Endpoints\Indices\Status; |
17
|
|
|
use Manticoresearch\Endpoints\Indices\Truncate; |
18
|
|
|
use Manticoresearch\Endpoints\Sql; |
19
|
|
|
use Manticoresearch\Exceptions\RuntimeException; |
20
|
|
|
|
21
|
|
|
class Indices |
22
|
|
|
{ |
23
|
|
|
use Utils; |
24
|
|
|
/** |
25
|
|
|
* @var Client |
26
|
|
|
*/ |
27
|
|
|
protected $_client; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
protected $_params; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Pq constructor. |
36
|
|
|
* @param $client |
37
|
|
|
*/ |
38
|
|
|
public function __construct($client) |
39
|
|
|
{ |
40
|
|
|
$this->_client = $client; |
41
|
|
|
$this->_params = ['responseClass' => 'Manticoresearch\\Response\\SqlToArray']; |
42
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param $params |
47
|
|
|
* @return mixed |
48
|
|
|
*/ |
49
|
|
|
public function alter($params) |
50
|
|
|
{ |
51
|
|
|
$index = $params['index'] ?? null; |
52
|
|
|
$body = $params['body']; |
53
|
|
|
$endpoint = new Alter(); |
54
|
|
|
$endpoint->setIndex($index); |
55
|
|
|
$endpoint->setBody($body); |
56
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
57
|
|
|
return $response->getResponse(); |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* |
64
|
|
|
* @param $params |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function create($params) |
68
|
|
|
{ |
69
|
|
|
|
70
|
|
|
$index = $params['index'] ?? null; |
71
|
|
|
$body = $params['body']; |
72
|
|
|
$endpoint = new Create(); |
73
|
|
|
$endpoint->setIndex($index); |
74
|
|
|
$endpoint->setBody($body); |
75
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
76
|
|
|
return $response->getResponse(); |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param $params |
82
|
|
|
* @return mixed |
83
|
|
|
*/ |
84
|
|
|
public function describe($params) |
85
|
|
|
{ |
86
|
|
|
$index = $params['index'] ?? null; |
87
|
|
|
$body = $params['body'] ?? []; |
88
|
|
|
$endpoint = new Describe(); |
89
|
|
|
$endpoint->setIndex($index); |
90
|
|
|
$endpoint->setBody($body); |
91
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
92
|
|
|
return $response->getResponse(); |
93
|
|
|
|
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param $params |
98
|
|
|
* @return mixed |
99
|
|
|
*/ |
100
|
|
|
public function drop($params) |
101
|
|
|
{ |
102
|
|
|
$index = $params['index'] ?? null; |
103
|
|
|
$body = $params['body'] ?? []; |
104
|
|
|
$endpoint = new Drop(); |
105
|
|
|
$endpoint->setIndex($index); |
106
|
|
|
$endpoint->setBody($body); |
107
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
108
|
|
|
return $response->getResponse(); |
109
|
|
|
} |
110
|
|
|
/** |
111
|
|
|
* @param $params |
112
|
|
|
* @return mixed |
113
|
|
|
*/ |
114
|
|
|
public function import($params) |
115
|
|
|
{ |
116
|
|
|
$index = $params['index'] ?? null; |
117
|
|
|
$body = $params['body'] ?? []; |
118
|
|
|
$endpoint = new Import(); |
119
|
|
|
$endpoint->setIndex($index); |
120
|
|
|
$endpoint->setBody($body); |
121
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
122
|
|
|
return $response->getResponse(); |
123
|
|
|
} |
124
|
|
|
/** |
125
|
|
|
* @param $params |
126
|
|
|
* @return mixed |
127
|
|
|
*/ |
128
|
|
|
public function flushramchunk($params) |
129
|
|
|
{ |
130
|
|
|
$index = $params['index'] ?? null; |
131
|
|
|
$endpoint = new FlushRamchunk(); |
132
|
|
|
$endpoint->setIndex($index); |
133
|
|
|
$endpoint->setBody(); |
134
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
135
|
|
|
return $response->getResponse(); |
136
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param $params |
141
|
|
|
* @return mixed |
142
|
|
|
*/ |
143
|
|
|
public function flushrtindex($params) |
144
|
|
|
{ |
145
|
|
|
$index = $params['index'] ?? null; |
146
|
|
|
$endpoint = new FlushRtindex(); |
147
|
|
|
$endpoint->setIndex($index); |
148
|
|
|
$endpoint->setBody(); |
149
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
150
|
|
|
return $response->getResponse(); |
151
|
|
|
|
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param $params |
156
|
|
|
* @return mixed |
157
|
|
|
*/ |
158
|
|
|
public function optimize($params) |
159
|
|
|
{ |
160
|
|
|
$index = $params['index'] ?? null; |
161
|
|
|
$body = $params['body'] ?? null; |
162
|
|
|
$endpoint = new Optimize(); |
163
|
|
|
$endpoint->setIndex($index); |
164
|
|
|
$endpoint->setBody($body); |
165
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
166
|
|
|
return $response->getResponse(); |
167
|
|
|
|
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @param $params |
172
|
|
|
* @return mixed |
173
|
|
|
*/ |
174
|
|
|
public function status($params) |
175
|
|
|
{ |
176
|
|
|
$index = $params['index'] ?? null; |
177
|
|
|
$body = $params['body'] ?? null; |
178
|
|
|
$endpoint = new Status(); |
179
|
|
|
$endpoint->setIndex($index); |
180
|
|
|
$endpoint->setBody($body); |
181
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
182
|
|
|
return $response->getResponse(); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param $params |
187
|
|
|
* @return array|mixed|string |
188
|
|
|
*/ |
189
|
|
|
public function settings($params) |
190
|
|
|
{ |
191
|
|
|
$index = $params['index'] ?? null; |
192
|
|
|
$body = $params['body'] ?? null; |
193
|
|
|
$endpoint = new Settings(); |
194
|
|
|
$endpoint->setIndex($index); |
195
|
|
|
$endpoint->setBody($body); |
196
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
197
|
|
|
return $response->getResponse(); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @param $params |
202
|
|
|
* @return mixed |
203
|
|
|
*/ |
204
|
|
|
public function truncate($params) |
205
|
|
|
{ |
206
|
|
|
$index = $params['index'] ?? null; |
207
|
|
|
$body = $params['body'] ?? null; |
208
|
|
|
$endpoint = new Truncate(); |
209
|
|
|
$endpoint->setIndex($index); |
210
|
|
|
$endpoint->setBody($body); |
211
|
|
|
$response = $this->_client->request($endpoint, $this->_params); |
212
|
|
|
return $response->getResponse(); |
213
|
|
|
|
214
|
|
|
} |
215
|
|
|
} |
216
|
|
|
|