Skip to content

Commit 7cf24fd

Browse files
committed
Simplify search index definition type
1 parent b38f88f commit 7cf24fd

File tree

1 file changed

+10
-94
lines changed

1 file changed

+10
-94
lines changed

src/Schema/Blueprint.php

+10-94
Original file line numberDiff line numberDiff line change
@@ -16,98 +16,6 @@
1616
use function is_string;
1717
use function key;
1818

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-
*/
11119
class Blueprint extends SchemaBlueprint
11220
{
11321
/**
@@ -400,7 +308,15 @@ public function sparse_and_unique($columns = null, $options = [])
400308
*
401309
* @see https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/#std-label-search-index-definition-create
402310
*
403-
* @phpstan-param TypeSearchIndexDefinition $definition
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
404320
*/
405321
public function searchIndex(array $definition, string $name = 'default'): static
406322
{
@@ -414,7 +330,7 @@ public function searchIndex(array $definition, string $name = 'default'): static
414330
*
415331
* @see https://www.mongodb.com/docs/manual/reference/command/createSearchIndexes/#std-label-vector-search-index-definition-create
416332
*
417-
* @phpstan-param TypeVectorSearchIndexDefinition $definition
333+
* @phpstan-param array{fields: array<string, array{type: string, ...}>} $definition
418334
*/
419335
public function vectorSearchIndex(array $definition, string $name = 'default'): static
420336
{

0 commit comments

Comments
 (0)