1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AmaTeam\ElasticSearch\Mapping; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
7
|
|
|
*/ |
8
|
|
|
class Mapping // NOSONAR |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Type itself |
12
|
|
|
* |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $type = TypeEnum::ROOT; |
16
|
|
|
/** |
17
|
|
|
* Whether to automatically create mapping for nested properties. |
18
|
|
|
* |
19
|
|
|
* Applicable only for object and nested types. |
20
|
|
|
* |
21
|
|
|
* @var bool|string |
22
|
|
|
*/ |
23
|
|
|
private $dynamic; |
24
|
|
|
/** |
25
|
|
|
* Type format |
26
|
|
|
* |
27
|
|
|
* @var string|null |
28
|
|
|
*/ |
29
|
|
|
private $format; |
30
|
|
|
/** |
31
|
|
|
* @var bool |
32
|
|
|
*/ |
33
|
|
|
private $coerce; |
34
|
|
|
/** |
35
|
|
|
* @var string|null |
36
|
|
|
*/ |
37
|
|
|
private $copyTo; |
38
|
|
|
/** |
39
|
|
|
* @var bool |
40
|
|
|
*/ |
41
|
|
|
private $store; |
42
|
|
|
/** |
43
|
|
|
* @var bool |
44
|
|
|
*/ |
45
|
|
|
private $index; |
46
|
|
|
/** |
47
|
|
|
* @var string|null |
48
|
|
|
*/ |
49
|
|
|
private $indexOptions; |
50
|
|
|
/** |
51
|
|
|
* @var bool |
52
|
|
|
*/ |
53
|
|
|
private $docValues; |
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
private $analyzer; |
58
|
|
|
/** |
59
|
|
|
* @var bool |
60
|
|
|
*/ |
61
|
|
|
private $norms; |
62
|
|
|
/** |
63
|
|
|
* @var bool |
64
|
|
|
*/ |
65
|
|
|
private $fieldData; |
66
|
|
|
/** |
67
|
|
|
* @var bool |
68
|
|
|
*/ |
69
|
|
|
private $enabled; |
70
|
|
|
/** |
71
|
|
|
* @var null|integer |
72
|
|
|
*/ |
73
|
|
|
private $ignoreAbove; |
74
|
|
|
/** |
75
|
|
|
* @var bool |
76
|
|
|
*/ |
77
|
|
|
private $ignoreMalformed; |
78
|
|
|
/** |
79
|
|
|
* @var Mapping[] |
80
|
|
|
*/ |
81
|
|
|
private $properties = []; |
82
|
|
|
/** |
83
|
|
|
* @var mixed |
84
|
|
|
*/ |
85
|
|
|
private $nullValue; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getType() |
91
|
|
|
{ |
92
|
|
|
return $this->type; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $type |
97
|
|
|
* @return $this |
98
|
|
|
*/ |
99
|
|
|
public function setType($type) |
100
|
|
|
{ |
101
|
|
|
$this->type = $type; |
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
public function isDynamic() |
109
|
|
|
{ |
110
|
|
|
return $this->dynamic; |
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param bool $dynamic |
115
|
|
|
* @return $this |
116
|
|
|
*/ |
117
|
|
|
public function setDynamic($dynamic) |
118
|
|
|
{ |
119
|
|
|
$this->dynamic = $dynamic; |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getFormat() |
127
|
|
|
{ |
128
|
|
|
return $this->format; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $format |
133
|
|
|
* @return $this |
134
|
|
|
*/ |
135
|
|
|
public function setFormat($format) |
136
|
|
|
{ |
137
|
|
|
$this->format = $format; |
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return bool |
143
|
|
|
*/ |
144
|
|
|
public function isCoerce() |
145
|
|
|
{ |
146
|
|
|
return $this->coerce; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param bool $coerce |
151
|
|
|
* @return $this |
152
|
|
|
*/ |
153
|
|
|
public function setCoerce($coerce) |
154
|
|
|
{ |
155
|
|
|
$this->coerce = $coerce; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return null|string |
161
|
|
|
*/ |
162
|
|
|
public function getCopyTo() |
163
|
|
|
{ |
164
|
|
|
return $this->copyTo; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @param null|string $copyTo |
169
|
|
|
* @return $this |
170
|
|
|
*/ |
171
|
|
|
public function setCopyTo($copyTo) |
172
|
|
|
{ |
173
|
|
|
$this->copyTo = $copyTo; |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return bool |
179
|
|
|
*/ |
180
|
|
|
public function isStore() |
181
|
|
|
{ |
182
|
|
|
return $this->store; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param bool $store |
187
|
|
|
* @return $this |
188
|
|
|
*/ |
189
|
|
|
public function setStore($store) |
190
|
|
|
{ |
191
|
|
|
$this->store = $store; |
192
|
|
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return bool |
197
|
|
|
*/ |
198
|
|
|
public function isIndex() |
199
|
|
|
{ |
200
|
|
|
return $this->index; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param bool $index |
205
|
|
|
* @return $this |
206
|
|
|
*/ |
207
|
|
|
public function setIndex($index) |
208
|
|
|
{ |
209
|
|
|
$this->index = $index; |
210
|
|
|
return $this; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @return string |
215
|
|
|
*/ |
216
|
|
|
public function getIndexOptions() |
217
|
|
|
{ |
218
|
|
|
return $this->indexOptions; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* @param string $indexOptions |
223
|
|
|
* @return $this |
224
|
|
|
*/ |
225
|
|
|
public function setIndexOptions($indexOptions) |
226
|
|
|
{ |
227
|
|
|
$this->indexOptions = $indexOptions; |
228
|
|
|
return $this; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @return bool |
233
|
|
|
*/ |
234
|
|
|
public function isDocValues() |
235
|
|
|
{ |
236
|
|
|
return $this->docValues; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* @param bool $docValues |
241
|
|
|
* @return $this |
242
|
|
|
*/ |
243
|
|
|
public function setDocValues($docValues) |
244
|
|
|
{ |
245
|
|
|
$this->docValues = $docValues; |
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return string |
251
|
|
|
*/ |
252
|
|
|
public function getAnalyzer() |
253
|
|
|
{ |
254
|
|
|
return $this->analyzer; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @param string $analyzer |
259
|
|
|
* @return $this |
260
|
|
|
*/ |
261
|
|
|
public function setAnalyzer($analyzer) |
262
|
|
|
{ |
263
|
|
|
$this->analyzer = $analyzer; |
264
|
|
|
return $this; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @return bool |
269
|
|
|
*/ |
270
|
|
|
public function isNorms() |
271
|
|
|
{ |
272
|
|
|
return $this->norms; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @param bool $norms |
277
|
|
|
* @return $this |
278
|
|
|
*/ |
279
|
|
|
public function setNorms($norms) |
280
|
|
|
{ |
281
|
|
|
$this->norms = $norms; |
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @return bool |
287
|
|
|
*/ |
288
|
|
|
public function isFieldData() |
289
|
|
|
{ |
290
|
|
|
return $this->fieldData; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* @param bool $fieldData |
295
|
|
|
* @return $this |
296
|
|
|
*/ |
297
|
|
|
public function setFieldData($fieldData) |
298
|
|
|
{ |
299
|
|
|
$this->fieldData = $fieldData; |
300
|
|
|
return $this; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* @return bool |
305
|
|
|
*/ |
306
|
|
|
public function isEnabled() |
307
|
|
|
{ |
308
|
|
|
return $this->enabled; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* @param bool $enabled |
313
|
|
|
* @return $this |
314
|
|
|
*/ |
315
|
|
|
public function setEnabled($enabled) |
316
|
|
|
{ |
317
|
|
|
$this->enabled = $enabled; |
318
|
|
|
return $this; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* @return int|null |
323
|
|
|
*/ |
324
|
|
|
public function getIgnoreAbove() |
325
|
|
|
{ |
326
|
|
|
return $this->ignoreAbove; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* @param int|null $ignoreAbove |
331
|
|
|
* @return $this |
332
|
|
|
*/ |
333
|
|
|
public function setIgnoreAbove($ignoreAbove) |
334
|
|
|
{ |
335
|
|
|
$this->ignoreAbove = $ignoreAbove; |
336
|
|
|
return $this; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @return bool |
341
|
|
|
*/ |
342
|
|
|
public function isIgnoreMalformed() |
343
|
|
|
{ |
344
|
|
|
return $this->ignoreMalformed; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
/** |
348
|
|
|
* @param bool $ignoreMalformed |
349
|
|
|
* @return $this |
350
|
|
|
*/ |
351
|
|
|
public function setIgnoreMalformed($ignoreMalformed) |
352
|
|
|
{ |
353
|
|
|
$this->ignoreMalformed = $ignoreMalformed; |
354
|
|
|
return $this; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* @return Mapping[] |
359
|
|
|
*/ |
360
|
|
|
public function getProperties() |
361
|
|
|
{ |
362
|
|
|
return $this->properties; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
/** |
366
|
|
|
* @param Mapping[] $properties |
367
|
|
|
* @return $this |
368
|
|
|
*/ |
369
|
|
|
public function setProperties(array $properties) |
370
|
|
|
{ |
371
|
|
|
$this->properties = $properties; |
372
|
|
|
return $this; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* @return mixed |
377
|
|
|
*/ |
378
|
|
|
public function getNullValue() |
379
|
|
|
{ |
380
|
|
|
return $this->nullValue; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
/** |
384
|
|
|
* @param mixed $nullValue |
385
|
|
|
* @return $this |
386
|
|
|
*/ |
387
|
|
|
public function setNullValue($nullValue) |
388
|
|
|
{ |
389
|
|
|
$this->nullValue = $nullValue; |
390
|
|
|
return $this; |
391
|
|
|
} |
392
|
|
|
} |
393
|
|
|
|