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