16
16
use function is_string ;
17
17
use function key ;
18
18
19
+ /**
20
+ * @link https://www.mongodb.com/docs/atlas/atlas-search/define-field-mappings/#std-label-fts-field-mappings
21
+ * @phpstan-type TypeSearchIndexField array{
22
+ * type: 'boolean'|'date'|'dateFacet'|'objectId'|'stringFacet'|'uuid',
23
+ * } | array{
24
+ * type: 'autocomplete',
25
+ * analyzer?: string,
26
+ * maxGrams?: int,
27
+ * minGrams?: int,
28
+ * tokenization?: 'edgeGram'|'rightEdgeGram'|'nGram',
29
+ * foldDiacritics?: bool,
30
+ * } | array{
31
+ * type: 'document'|'embeddedDocuments',
32
+ * dynamic?:bool,
33
+ * fields: array<string, array<mixed>>,
34
+ * } | array{
35
+ * type: 'geo',
36
+ * indexShapes?: bool,
37
+ * } | array{
38
+ * type: 'number'|'numberFacet',
39
+ * representation?: 'int64'|'double',
40
+ * indexIntegers?: bool,
41
+ * indexDoubles?: bool,
42
+ * } | array{
43
+ * type: 'token',
44
+ * normalizer?: 'lowercase'|'none',
45
+ * } | array{
46
+ * type: 'string',
47
+ * analyzer?: string,
48
+ * searchAnalyzer?: string,
49
+ * indexOptions?: 'docs'|'freqs'|'positions'|'offsets',
50
+ * store?: bool,
51
+ * ignoreAbove?: int,
52
+ * multi?: array<string, array<string, mixed>>,
53
+ * norms?: 'include'|'omit',
54
+ * }
55
+ * @link https://www.mongodb.com/docs/atlas/atlas-search/analyzers/character-filters/
56
+ * @phpstan-type TypeSearchIndexCharFilter array{
57
+ * type: 'icuNormalize'|'persian',
58
+ * } | array{
59
+ * type: 'htmlStrip',
60
+ * ignoredTags?: string[],
61
+ * } | array{
62
+ * type: 'mapping',
63
+ * mappings?: array<string, string>,
64
+ * }
65
+ * @link https://www.mongodb.com/docs/atlas/atlas-search/analyzers/token-filters/
66
+ * @phpstan-type TypeSearchIndexTokenFilter array{type: string, ...}
67
+ * @link https://www.mongodb.com/docs/atlas/atlas-search/analyzers/custom/
68
+ * @phpstan-type TypeSearchIndexAnalyzer array{
69
+ * name: string,
70
+ * charFilters?: TypeSearchIndexCharFilter,
71
+ * tokenizer: array{type: string},
72
+ * tokenFilters?: TypeSearchIndexTokenFilter,
73
+ * }
74
+ * @link https://www.mongodb.com/docs/atlas/atlas-search/stored-source-definition/#std-label-fts-stored-source-definition
75
+ * @phpstan-type TypeSearchIndexStoredSource bool | array{
76
+ * includes: array<string>,
77
+ * } | array{
78
+ * excludes: array<string>,
79
+ * }
80
+ * @link https://www.mongodb.com/docs/atlas/atlas-search/synonyms/#std-label-synonyms-ref
81
+ * @phpstan-type TypeSearchIndexSynonyms array{
82
+ * analyzer: string,
83
+ * name: string,
84
+ * source?: array{collection: string},
85
+ * }
86
+ * @link https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/#std-label-search-index-definition-create
87
+ * @phpstan-type TypeSearchIndexDefinition array{
88
+ * analyzer?: string,
89
+ * analyzers?: TypeSearchIndexAnalyzer[],
90
+ * searchAnalyzer?: string,
91
+ * mappings: array{dynamic: true} | array{dynamic?: bool, fields: array<string, TypeSearchIndexField|TypeSearchIndexField[]>},
92
+ * storedSource?: TypeSearchIndexStoredSource,
93
+ * synonyms?: TypeSearchIndexSynonyms[],
94
+ * }
95
+ * @link https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#atlas-vector-search-index-fields
96
+ * @phpstan-type TypeVectorSearchIndexField array{
97
+ * type: 'vector',
98
+ * path: string,
99
+ * numDimensions: int,
100
+ * similarity: 'euclidean'|'cosine'|'dotProduct',
101
+ * quantization?: 'none'|'scalar'|'binary',
102
+ * } | array{
103
+ * type: 'filter',
104
+ * path: string,
105
+ * }
106
+ * @link https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#atlas-vector-search-index-fields
107
+ * @phpstan-type TypeVectorSearchIndexDefinition array{
108
+ * fields: array<string, TypeVectorSearchIndexField>,
109
+ * }
110
+ */
19
111
class Blueprint extends SchemaBlueprint
20
112
{
21
113
/**
@@ -308,15 +400,7 @@ public function sparse_and_unique($columns = null, $options = [])
308
400
*
309
401
* @see https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/#std-label-search-index-definition-create
310
402
*
311
- * @phpstan-param array{
312
- * analyzer?: string,
313
- * analyzers?: list<array>,
314
- * searchAnalyzer?: string,
315
- * mappings: array{dynamic: true} | array{dynamic?: bool, fields: array<string, array>},
316
- * storedSource?: bool|array,
317
- * synonyms?: list<array>,
318
- * ...
319
- * } $definition
403
+ * @phpstan-param TypeSearchIndexDefinition $definition
320
404
*/
321
405
public function searchIndex (array $ definition , string $ name = 'default ' ): static
322
406
{
@@ -330,7 +414,7 @@ public function searchIndex(array $definition, string $name = 'default'): static
330
414
*
331
415
* @see https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/#std-label-vector-search-index-definition-create
332
416
*
333
- * @phpstan-param array{fields: array<string, array{type: string, ...}>} $definition
417
+ * @phpstan-param TypeVectorSearchIndexDefinition $definition
334
418
*/
335
419
public function vectorSearchIndex (array $ definition , string $ name = 'default ' ): static
336
420
{
0 commit comments