1 | <?php |
||
7 | class Blueprint |
||
8 | { |
||
9 | /** @var Fluent[] */ |
||
10 | private $fields = []; |
||
11 | |||
12 | /** @var array|null */ |
||
13 | private $settings; |
||
14 | |||
15 | /** |
||
16 | * Blueprint constructor. |
||
17 | * @param \Closure|null $callback |
||
18 | */ |
||
19 | 7 | public function __construct(\Closure $callback = null) |
|
25 | |||
26 | /** |
||
27 | * Build a mapping |
||
28 | * |
||
29 | * @param string $esIndex |
||
30 | * @param string $esType |
||
31 | * @return array |
||
32 | */ |
||
33 | 2 | public function build(string $esIndex, string $esType) : array |
|
41 | |||
42 | 2 | private function shouldCreateIndex(string $esIndex) : bool |
|
46 | |||
47 | 1 | private function createIndex(string $index, string $type) : array |
|
66 | |||
67 | 1 | private function updateIndex(string $index, string $type) : array |
|
82 | |||
83 | /** |
||
84 | * To dsl |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | 4 | public function toDsl() : array |
|
92 | |||
93 | /** |
||
94 | * Get fields |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | 3 | public function getFields() : array |
|
102 | |||
103 | /** |
||
104 | * Text |
||
105 | * |
||
106 | * @param string $field |
||
107 | * @param array $attributes |
||
108 | * @return Fluent |
||
109 | */ |
||
110 | 4 | public function text(string $field, array $attributes = []) : Fluent |
|
114 | |||
115 | /** |
||
116 | * Keyword |
||
117 | * |
||
118 | * @param string $field |
||
119 | * @param array $attributes |
||
120 | * @return Fluent |
||
121 | */ |
||
122 | 5 | public function keyword(string $field, array $attributes = []) : Fluent |
|
126 | |||
127 | /** |
||
128 | * Long |
||
129 | * |
||
130 | * @param string $field |
||
131 | * @param array $attributes |
||
132 | * @return Fluent |
||
133 | */ |
||
134 | 1 | public function long(string $field, array $attributes = []) : Fluent |
|
138 | |||
139 | /** |
||
140 | * Integer |
||
141 | * |
||
142 | * @param string $field |
||
143 | * @param array $attributes |
||
144 | * @return Fluent |
||
145 | */ |
||
146 | 3 | public function integer(string $field, array $attributes = []) : Fluent |
|
150 | |||
151 | /** |
||
152 | * Short |
||
153 | * |
||
154 | * @param string $field |
||
155 | * @param array $attributes |
||
156 | * @return Fluent |
||
157 | */ |
||
158 | 1 | public function short(string $field, array $attributes = []) : Fluent |
|
162 | |||
163 | /** |
||
164 | * Byte |
||
165 | * |
||
166 | * @param string $field |
||
167 | * @param array $attributes |
||
168 | * @return Fluent |
||
169 | */ |
||
170 | 1 | public function byte(string $field, array $attributes = []) : Fluent |
|
174 | |||
175 | /** |
||
176 | * Double |
||
177 | * |
||
178 | * @param string $field |
||
179 | * @param array $attributes |
||
180 | * @return Fluent |
||
181 | */ |
||
182 | 1 | public function double(string $field, array $attributes = []) : Fluent |
|
186 | |||
187 | /** |
||
188 | * Float |
||
189 | * |
||
190 | * @param string $field |
||
191 | * @param array $attributes |
||
192 | * @return Fluent |
||
193 | */ |
||
194 | 1 | public function float(string $field, array $attributes = []) : Fluent |
|
198 | |||
199 | /** |
||
200 | * Half float |
||
201 | * |
||
202 | * @param string $field |
||
203 | * @param array $attributes |
||
204 | * @return Fluent |
||
205 | */ |
||
206 | 1 | public function halfFloat(string $field, array $attributes = []) : Fluent |
|
210 | |||
211 | /** |
||
212 | * Scaled float |
||
213 | * |
||
214 | * @param string $field |
||
215 | * @param array $attributes |
||
216 | * @return Fluent |
||
217 | */ |
||
218 | 1 | public function scaledFloat(string $field, array $attributes = []) : Fluent |
|
222 | |||
223 | /** |
||
224 | * Date |
||
225 | * |
||
226 | * @param string $field |
||
227 | * @param array $attributes |
||
228 | * @return Fluent |
||
229 | */ |
||
230 | 1 | public function date(string $field, array $attributes = []) : Fluent |
|
234 | |||
235 | /** |
||
236 | * Boolean |
||
237 | * |
||
238 | * @param string $field |
||
239 | * @param array $attributes |
||
240 | * @return Fluent |
||
241 | */ |
||
242 | 1 | public function boolean(string $field, array $attributes = []) : Fluent |
|
246 | |||
247 | /** |
||
248 | * Binary |
||
249 | * |
||
250 | * @param string $field |
||
251 | * @param array $attributes |
||
252 | * @return Fluent |
||
253 | */ |
||
254 | 1 | public function binary(string $field, array $attributes = []) : Fluent |
|
258 | |||
259 | /** |
||
260 | * Range |
||
261 | * |
||
262 | * @param string $field |
||
263 | * @param string $type |
||
264 | * @param array $attributes |
||
265 | * @return Fluent |
||
266 | * |
||
267 | * @throws \InvalidArgumentException |
||
268 | */ |
||
269 | 2 | public function range(string $field, string $type, array $attributes = []) : Fluent |
|
286 | |||
287 | /** |
||
288 | * Nested |
||
289 | * |
||
290 | * @param string $field |
||
291 | * @param array $attributes |
||
292 | * @return Fluent |
||
293 | */ |
||
294 | 1 | public function nested(string $field, array $attributes = []) : Fluent |
|
298 | |||
299 | /** |
||
300 | * Object |
||
301 | * |
||
302 | * @param string $field |
||
303 | * @param array $attributes |
||
304 | * @return Fluent |
||
305 | */ |
||
306 | 1 | public function object(string $field, array $attributes = []) : Fluent |
|
310 | |||
311 | /** |
||
312 | * Geo point |
||
313 | * |
||
314 | * @param string $field |
||
315 | * @param array $attributes |
||
316 | * @return Fluent |
||
317 | */ |
||
318 | 1 | public function geoPoint(string $field, array $attributes = []) : Fluent |
|
322 | |||
323 | /** |
||
324 | * Geo shape |
||
325 | * |
||
326 | * @param string $field |
||
327 | * @param array $attributes |
||
328 | * @return Fluent |
||
329 | */ |
||
330 | 1 | public function geoShape(string $field, array $attributes = []) : Fluent |
|
334 | |||
335 | /** |
||
336 | * Ip |
||
337 | * |
||
338 | * @param string $field |
||
339 | * @param array $attributes |
||
340 | * @return Fluent |
||
341 | */ |
||
342 | 1 | public function ip(string $field, array $attributes = []) : Fluent |
|
346 | |||
347 | /** |
||
348 | * Completion |
||
349 | * |
||
350 | * @param string $field |
||
351 | * @param array $attributes |
||
352 | * @return Fluent |
||
353 | */ |
||
354 | 1 | public function completion(string $field, array $attributes = []) : Fluent |
|
358 | |||
359 | /** |
||
360 | * Token count |
||
361 | * |
||
362 | * @param string $field |
||
363 | * @param array $attributes |
||
364 | * @return Fluent |
||
365 | */ |
||
366 | 1 | public function tokenCount(string $field, array $attributes = []) : Fluent |
|
370 | |||
371 | /** |
||
372 | * Add field |
||
373 | * |
||
374 | * @param string $type |
||
375 | * @param string $name |
||
376 | * @param array $attributes |
||
377 | * @return Fluent |
||
378 | */ |
||
379 | 6 | public function addField(string $type, string $name, array $attributes = []) : Fluent |
|
393 | |||
394 | /** |
||
395 | * Settings |
||
396 | * |
||
397 | * @param array $settings |
||
398 | */ |
||
399 | 2 | public function settings(array $settings) |
|
403 | } |
||
404 |