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