@zilliz/milvus2-sdk-node 2.6.11 → 2.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +815 -41
  2. package/dist/milvus/HttpClient.d.ts +10 -10
  3. package/dist/milvus/MilvusClient.js +6 -3
  4. package/dist/milvus/MilvusClient.js.map +1 -1
  5. package/dist/milvus/bulkwriter/BulkWriter.d.ts +35 -0
  6. package/dist/milvus/bulkwriter/BulkWriter.js +315 -0
  7. package/dist/milvus/bulkwriter/BulkWriter.js.map +1 -0
  8. package/dist/milvus/bulkwriter/ColumnBuffer.d.ts +18 -0
  9. package/dist/milvus/bulkwriter/ColumnBuffer.js +131 -0
  10. package/dist/milvus/bulkwriter/ColumnBuffer.js.map +1 -0
  11. package/dist/milvus/bulkwriter/JsonFormatter.d.ts +5 -0
  12. package/dist/milvus/bulkwriter/JsonFormatter.js +213 -0
  13. package/dist/milvus/bulkwriter/JsonFormatter.js.map +1 -0
  14. package/dist/milvus/bulkwriter/LocalStorage.d.ts +4 -0
  15. package/dist/milvus/bulkwriter/LocalStorage.js +21 -0
  16. package/dist/milvus/bulkwriter/LocalStorage.js.map +1 -0
  17. package/dist/milvus/bulkwriter/ParquetFormatter.d.ts +5 -0
  18. package/dist/milvus/bulkwriter/ParquetFormatter.js +326 -0
  19. package/dist/milvus/bulkwriter/ParquetFormatter.js.map +1 -0
  20. package/dist/milvus/bulkwriter/Types.d.ts +27 -0
  21. package/dist/milvus/bulkwriter/Types.js +3 -0
  22. package/dist/milvus/bulkwriter/Types.js.map +1 -0
  23. package/dist/milvus/bulkwriter/index.d.ts +6 -0
  24. package/dist/milvus/bulkwriter/index.js +14 -0
  25. package/dist/milvus/bulkwriter/index.js.map +1 -0
  26. package/dist/milvus/const/error.d.ts +1 -0
  27. package/dist/milvus/const/error.js +2 -1
  28. package/dist/milvus/const/error.js.map +1 -1
  29. package/dist/milvus/const/milvus.d.ts +3 -1
  30. package/dist/milvus/const/milvus.js +2 -0
  31. package/dist/milvus/const/milvus.js.map +1 -1
  32. package/dist/milvus/grpc/BaseClient.d.ts +7 -1
  33. package/dist/milvus/grpc/BaseClient.js +17 -2
  34. package/dist/milvus/grpc/BaseClient.js.map +1 -1
  35. package/dist/milvus/grpc/Collection.d.ts +52 -3
  36. package/dist/milvus/grpc/Collection.js +70 -2
  37. package/dist/milvus/grpc/Collection.js.map +1 -1
  38. package/dist/milvus/grpc/Data.d.ts +96 -4
  39. package/dist/milvus/grpc/Data.js +139 -13
  40. package/dist/milvus/grpc/Data.js.map +1 -1
  41. package/dist/milvus/grpc/GrpcClient.d.ts +19 -3
  42. package/dist/milvus/grpc/GrpcClient.js +168 -10
  43. package/dist/milvus/grpc/GrpcClient.js.map +1 -1
  44. package/dist/milvus/grpc/MilvusIndex.d.ts +22 -0
  45. package/dist/milvus/grpc/MilvusIndex.js +28 -0
  46. package/dist/milvus/grpc/MilvusIndex.js.map +1 -1
  47. package/dist/milvus/http/Alias.d.ts +1 -1
  48. package/dist/milvus/http/Collection.d.ts +1 -1
  49. package/dist/milvus/http/Database.d.ts +1 -1
  50. package/dist/milvus/http/Import.d.ts +1 -1
  51. package/dist/milvus/http/MilvusIndex.d.ts +1 -1
  52. package/dist/milvus/http/Partition.d.ts +1 -1
  53. package/dist/milvus/http/Role.d.ts +1 -1
  54. package/dist/milvus/http/User.d.ts +1 -1
  55. package/dist/milvus/http/Vector.d.ts +1 -1
  56. package/dist/milvus/index.d.ts +1 -0
  57. package/dist/milvus/index.js +2 -0
  58. package/dist/milvus/index.js.map +1 -1
  59. package/dist/milvus/types/Client.d.ts +8 -3
  60. package/dist/milvus/types/Collection.d.ts +21 -1
  61. package/dist/milvus/types/GlobalCluster.d.ts +23 -0
  62. package/dist/milvus/types/GlobalCluster.js +12 -0
  63. package/dist/milvus/types/GlobalCluster.js.map +1 -0
  64. package/dist/milvus/types/Resource.d.ts +8 -2
  65. package/dist/milvus/types/Search.d.ts +42 -0
  66. package/dist/milvus/types/Search.js +7 -0
  67. package/dist/milvus/types/Search.js.map +1 -1
  68. package/dist/milvus/types/Segments.d.ts +33 -1
  69. package/dist/milvus/types/index.d.ts +1 -0
  70. package/dist/milvus/types/index.js +1 -0
  71. package/dist/milvus/types/index.js.map +1 -1
  72. package/dist/milvus/utils/Format.js +47 -39
  73. package/dist/milvus/utils/Format.js.map +1 -1
  74. package/dist/milvus/utils/Function.d.ts +14 -1
  75. package/dist/milvus/utils/Function.js +51 -22
  76. package/dist/milvus/utils/Function.js.map +1 -1
  77. package/dist/milvus/utils/GlobalTopology.d.ts +56 -0
  78. package/dist/milvus/utils/GlobalTopology.js +215 -0
  79. package/dist/milvus/utils/GlobalTopology.js.map +1 -0
  80. package/dist/milvus/utils/Grpc.js +3 -2
  81. package/dist/milvus/utils/Grpc.js.map +1 -1
  82. package/dist/milvus/utils/Schema.d.ts +1 -1
  83. package/dist/milvus/utils/Schema.js +4 -4
  84. package/dist/milvus/utils/Schema.js.map +1 -1
  85. package/dist/milvus/utils/Search.d.ts +54 -1
  86. package/dist/milvus/utils/Search.js +50 -4
  87. package/dist/milvus/utils/Search.js.map +1 -1
  88. package/dist/milvus/utils/index.d.ts +1 -0
  89. package/dist/milvus/utils/index.js +1 -0
  90. package/dist/milvus/utils/index.js.map +1 -1
  91. package/dist/sdk.json +1 -1
  92. package/package.json +5 -2
package/README.md CHANGED
@@ -1,69 +1,843 @@
1
- # Milvus2-sdk-node
1
+ # @zilliz/milvus2-sdk-node
2
2
 
3
- [![typescript](https://badges.aleen42.com/src/typescript.svg)](https://badges.aleen42.com/src/typescript.svg)
4
- [![version](https://img.shields.io/npm/v/@zilliz/milvus2-sdk-node?color=bright-green)](https://github.com/zilliztech/attu/releases)
5
- [![downloads](https://img.shields.io/npm/dw/@zilliz/milvus2-sdk-node?color=bright-green)](https://www.npmjs.com/package/@zilliz/milvus2-sdk-node)
6
- [![codecov](https://codecov.io/gh/milvus-io/milvus-sdk-node/branch/main/graph/badge.svg?token=Zu5FwWstwI)](https://codecov.io/gh/milvus-io/milvus-sdk-node)
7
-
8
- The official [Milvus](https://github.com/milvus-io/milvus) client for Node.js.
9
-
10
- ## 📚 Documentation
11
-
12
- **👉 [View Full Documentation](https://milvus-io.github.io/milvus-sdk-node)**
13
-
14
- For complete documentation, API reference, guides, and examples, please visit our documentation site.
15
-
16
- ## Compatibility
17
-
18
- The following table shows the recommended `@zilliz/milvus2-sdk-node` versions for different Milvus versions:
3
+ Official Node.js SDK for [Milvus](https://github.com/milvus-io/milvus) vector database. Provides gRPC and HTTP clients for vector similarity search, metadata filtering, and full collection/index/user management.
19
4
 
20
- | Milvus version | Node sdk version | Installation |
21
- | :------------: | :--------------: | :----------------------------------------- |
22
- | v2.6.0+ | **latest** | `yarn add @zilliz/milvus2-sdk-node@latest` |
23
- | v2.5.0+ | v2.5.0 | `yarn add @zilliz/milvus2-sdk-node@2.5.12` |
24
- | v2.4.0+ | v2.4.9 | `yarn add @zilliz/milvus2-sdk-node@2.4.9` |
25
- | v2.3.0+ | v2.3.5 | `yarn add @zilliz/milvus2-sdk-node@2.3.5` |
26
- | v2.2.0+ | v2.3.5 | `yarn add @zilliz/milvus2-sdk-node@2.3.5` |
5
+ **Package**: `@zilliz/milvus2-sdk-node` | **Node.js**: v18+ | **License**: Apache-2.0
27
6
 
28
- ## Dependencies
29
-
30
- - [Milvus](https://milvus.io/)
31
- - [Zilliz Cloud](https://cloud.zilliz.com/signup)
32
- - Node: v18+
7
+ [![npm version](https://img.shields.io/npm/v/@zilliz/milvus2-sdk-node)](https://www.npmjs.com/package/@zilliz/milvus2-sdk-node)
8
+ [![downloads](https://img.shields.io/npm/dw/@zilliz/milvus2-sdk-node)](https://www.npmjs.com/package/@zilliz/milvus2-sdk-node)
9
+ [![codecov](https://codecov.io/gh/milvus-io/milvus-sdk-node/branch/main/graph/badge.svg?token=Zu5FwWstwI)](https://codecov.io/gh/milvus-io/milvus-sdk-node)
33
10
 
34
11
  ## Installation
35
12
 
36
- ```shell
13
+ ```bash
37
14
  npm install @zilliz/milvus2-sdk-node
38
15
  # or
39
16
  yarn add @zilliz/milvus2-sdk-node
40
17
  ```
41
18
 
19
+ ## Compatibility
20
+
21
+ | Milvus version | SDK version | Install command |
22
+ | :------------: | :---------: | :------------------------------------------ |
23
+ | v2.6.0+ | **latest** | `yarn add @zilliz/milvus2-sdk-node@latest` |
24
+ | v2.5.0+ | v2.5.0 | `yarn add @zilliz/milvus2-sdk-node@2.5.12` |
25
+ | v2.4.0+ | v2.4.9 | `yarn add @zilliz/milvus2-sdk-node@2.4.9` |
26
+
42
27
  ## Quick Start
43
28
 
44
- ```javascript
29
+ ### Connect to Milvus
30
+
31
+ ```typescript
45
32
  import { MilvusClient } from '@zilliz/milvus2-sdk-node';
46
33
 
34
+ // Local Milvus
35
+ const client = new MilvusClient({ address: 'localhost:19530' });
36
+
37
+ // With authentication
47
38
  const client = new MilvusClient({
48
39
  address: 'localhost:19530',
40
+ username: 'root',
41
+ password: 'milvus',
49
42
  });
50
43
 
44
+ // Zilliz Cloud
45
+ const client = new MilvusClient({
46
+ address: 'your-endpoint.zillizcloud.com',
47
+ token: 'your-api-key',
48
+ });
49
+
50
+ // Wait for connection to be ready
51
51
  await client.connectPromise;
52
52
  ```
53
53
 
54
- For more examples and detailed usage, see the [documentation](https://milvus-io.github.io/milvus-sdk-node).
54
+ ### Create Collection, Insert, and Search
55
+
56
+ ```typescript
57
+ import {
58
+ MilvusClient,
59
+ DataType,
60
+ MetricType,
61
+ } from '@zilliz/milvus2-sdk-node';
62
+
63
+ const client = new MilvusClient({ address: 'localhost:19530' });
64
+
65
+ // 1. Create collection with schema
66
+ await client.createCollection({
67
+ collection_name: 'my_collection',
68
+ fields: [
69
+ { name: 'id', data_type: DataType.Int64, is_primary_key: true, autoID: true },
70
+ { name: 'text', data_type: DataType.VarChar, max_length: 512 },
71
+ { name: 'vector', data_type: DataType.FloatVector, dim: 128 },
72
+ ],
73
+ index_params: [
74
+ {
75
+ field_name: 'vector',
76
+ index_type: 'HNSW',
77
+ metric_type: MetricType.COSINE,
78
+ params: { M: 16, efConstruction: 256 },
79
+ },
80
+ ],
81
+ enable_dynamic_field: true,
82
+ });
83
+
84
+ // 2. Load into memory (required before search/query)
85
+ await client.loadCollection({ collection_name: 'my_collection' });
86
+
87
+ // 3. Insert data
88
+ await client.insert({
89
+ collection_name: 'my_collection',
90
+ data: [
91
+ { vector: Array(128).fill(0.1), text: 'doc1' },
92
+ { vector: Array(128).fill(0.2), text: 'doc2' },
93
+ ],
94
+ });
95
+
96
+ // 4. Search
97
+ const results = await client.search({
98
+ collection_name: 'my_collection',
99
+ data: [Array(128).fill(0.1)],
100
+ limit: 10,
101
+ output_fields: ['text'],
102
+ });
103
+ console.log(results.results);
104
+ ```
105
+
106
+ ---
107
+
108
+ ## API Reference
109
+
110
+ ### Imports
111
+
112
+ ```typescript
113
+ // Main client
114
+ import { MilvusClient } from '@zilliz/milvus2-sdk-node';
115
+
116
+ // HTTP client (for environments without gRPC support)
117
+ import { HttpClient } from '@zilliz/milvus2-sdk-node';
118
+
119
+ // Enums and constants
120
+ import {
121
+ DataType,
122
+ MetricType,
123
+ IndexType,
124
+ ConsistencyLevelEnum,
125
+ ErrorCode,
126
+ } from '@zilliz/milvus2-sdk-node';
127
+
128
+ // Bulk writer for large-scale imports
129
+ import { BulkWriter } from '@zilliz/milvus2-sdk-node';
130
+ ```
131
+
132
+ ### Client Configuration
133
+
134
+ ```typescript
135
+ new MilvusClient({
136
+ address: string; // Required. "host:port" or "https://host:port"
137
+ token?: string; // Auth token (username:password or API key)
138
+ username?: string; // Username for auth
139
+ password?: string; // Password for auth
140
+ ssl?: boolean; // Enable SSL/TLS
141
+ database?: string; // Default database name
142
+ timeout?: number | string; // Request timeout in ms (or string like '30s')
143
+ maxRetries?: number; // Max retry attempts (default: 3)
144
+ retryDelay?: number; // Retry delay in ms (default: 10)
145
+ logLevel?: string; // 'debug' | 'info' | 'warn' | 'error'
146
+ trace?: boolean; // Enable OpenTelemetry tracing
147
+ tls?: { // TLS certificate configuration
148
+ rootCertPath?: string;
149
+ privateKeyPath?: string;
150
+ certChainPath?: string;
151
+ serverName?: string;
152
+ skipCertCheck?: boolean;
153
+ };
154
+ pool?: { // Connection pool (generic-pool options)
155
+ max?: number; // Max connections (default: 10)
156
+ min?: number; // Min connections (default: 2)
157
+ };
158
+ });
159
+ ```
160
+
161
+ ---
162
+
163
+ ### Data Operations
164
+
165
+ #### insert
166
+
167
+ Insert rows into a collection.
168
+
169
+ ```typescript
170
+ await client.insert({
171
+ collection_name: string;
172
+ data: Record<string, any>[]; // Array of row objects
173
+ partition_name?: string;
174
+ });
175
+ // Returns: { succ_index: number[], err_index: number[], IDs: string[] | number[], ... }
176
+ ```
177
+
178
+ #### upsert
179
+
180
+ Insert or update rows (matched by primary key).
181
+
182
+ ```typescript
183
+ await client.upsert({
184
+ collection_name: string;
185
+ data: Record<string, any>[];
186
+ partition_name?: string;
187
+ });
188
+ ```
189
+
190
+ #### delete
191
+
192
+ Delete rows by filter expression or primary key IDs.
193
+
194
+ ```typescript
195
+ // By filter
196
+ await client.delete({
197
+ collection_name: 'articles',
198
+ filter: 'age > 18',
199
+ });
200
+
201
+ // By IDs
202
+ await client.delete({
203
+ collection_name: 'articles',
204
+ ids: [1, 2, 3],
205
+ });
206
+ ```
207
+
208
+ #### search
209
+
210
+ Vector similarity search.
211
+
212
+ ```typescript
213
+ const results = await client.search({
214
+ collection_name: string;
215
+ data: number[][] | number[]; // Query vector(s)
216
+ limit: number; // Top-K results (default: 100)
217
+ output_fields?: string[]; // Fields to return
218
+ filter?: string; // Scalar filter expression
219
+ metric_type?: MetricType; // Distance metric
220
+ params?: { // Index-specific search params
221
+ ef?: number; // HNSW ef (search width)
222
+ nprobe?: number; // IVF nprobe
223
+ radius?: number; // Range search radius
224
+ range_filter?: number; // Range search filter
225
+ };
226
+ consistency_level?: ConsistencyLevelEnum;
227
+ partition_names?: string[];
228
+ group_by_field?: string; // Group results by field
229
+ });
230
+ // Returns: { results: [{ id, score, ...output_fields }], ... }
231
+ ```
232
+
233
+ #### query
234
+
235
+ Query rows with scalar filter expression.
236
+
237
+ ```typescript
238
+ const results = await client.query({
239
+ collection_name: string;
240
+ filter: string; // Boolean expression, e.g. 'age > 18 AND status == "active"'
241
+ output_fields?: string[]; // Fields to return (default: all)
242
+ limit?: number;
243
+ offset?: number;
244
+ consistency_level?: ConsistencyLevelEnum;
245
+ partition_names?: string[];
246
+ });
247
+ // Returns: { data: Record<string, any>[] }
248
+ ```
249
+
250
+ #### get
251
+
252
+ Get rows by primary key IDs.
253
+
254
+ ```typescript
255
+ const results = await client.get({
256
+ collection_name: string;
257
+ ids: (string | number)[];
258
+ output_fields?: string[];
259
+ });
260
+ ```
261
+
262
+ #### count
263
+
264
+ Count rows matching a filter.
265
+
266
+ ```typescript
267
+ const result = await client.count({
268
+ collection_name: string;
269
+ filter?: string;
270
+ });
271
+ // Returns: { data: number }
272
+ ```
273
+
274
+ #### searchIterator
275
+
276
+ Paginated vector search using async iterator.
277
+
278
+ ```typescript
279
+ const iterator = await client.searchIterator({
280
+ collection_name: string;
281
+ data: number[];
282
+ batchSize: number;
283
+ limit: number;
284
+ output_fields?: string[];
285
+ filter?: string;
286
+ expr?: string;
287
+ });
288
+
289
+ for await (const batch of iterator) {
290
+ console.log(batch); // Array of results per batch
291
+ }
292
+ ```
293
+
294
+ #### queryIterator
295
+
296
+ Paginated query using async iterator.
297
+
298
+ ```typescript
299
+ const iterator = await client.queryIterator({
300
+ collection_name: string;
301
+ filter?: string;
302
+ batchSize: number;
303
+ limit: number;
304
+ output_fields?: string[];
305
+ expr?: string;
306
+ });
307
+
308
+ for await (const batch of iterator) {
309
+ console.log(batch);
310
+ }
311
+ ```
312
+
313
+ #### hybridSearch
314
+
315
+ Multi-vector search combining results from multiple vector fields with reranking.
316
+
317
+ ```typescript
318
+ const results = await client.hybridSearch({
319
+ collection_name: string;
320
+ rerank: WeightedReranker | RRFReranker; // Reranking strategy
321
+ requests: Array<{
322
+ data: number[][];
323
+ anns_field: string;
324
+ params?: Record<string, any>;
325
+ limit?: number;
326
+ filter?: string;
327
+ }>;
328
+ limit: number;
329
+ output_fields?: string[];
330
+ });
331
+ ```
332
+
333
+ ---
334
+
335
+ ### Collection Management
336
+
337
+ #### createCollection
338
+
339
+ ```typescript
340
+ await client.createCollection({
341
+ collection_name: string;
342
+ fields: FieldType[]; // Define schema fields
343
+ index_params?: CreateIndexParam[]; // Create indexes at collection creation time
344
+ enable_dynamic_field?: boolean; // Allow inserting fields not in schema
345
+ consistency_level?: ConsistencyLevelEnum;
346
+ num_partitions?: number;
347
+ });
348
+ // Note: call loadCollection() after creation before search/query
349
+ ```
350
+
351
+ #### Other collection operations
352
+
353
+ ```typescript
354
+ await client.hasCollection({ collection_name }); // { value: boolean }
355
+ await client.describeCollection({ collection_name }); // Schema, fields, properties
356
+ await client.batchDescribeCollections({ collection_names: string[] }); // Describe multiple collections
357
+ await client.showCollections(); // List all collections
358
+ await client.loadCollection({ collection_name }); // Load into memory
359
+ await client.releaseCollection({ collection_name }); // Release from memory
360
+ await client.refreshLoad({ collection_name }); // Refresh loaded collection
361
+ await client.dropCollection({ collection_name }); // Delete collection
362
+ await client.renameCollection({ collection_name, new_collection_name });
363
+ await client.truncateCollection({ collection_name }); // Clear all data
364
+ await client.getLoadState({ collection_name }); // Loading status
365
+ await client.getCollectionStatistics({ collection_name });
366
+ await client.alterCollectionProperties({ collection_name, properties });
367
+ await client.alterCollectionFieldProperties({ collection_name, field_name, properties });
368
+ await client.dropCollectionProperties({ collection_name, delete_keys: string[] });
369
+ await client.addCollectionFunction({ collection_name, functions });
370
+ await client.dropCollectionFunction({ collection_name, functions });
371
+ ```
372
+
373
+ ---
374
+
375
+ ### Index Management
376
+
377
+ ```typescript
378
+ // Create index
379
+ await client.createIndex({
380
+ collection_name: string;
381
+ field_name: string;
382
+ index_type?: IndexType; // Default: AUTOINDEX
383
+ metric_type?: MetricType; // Default: COSINE
384
+ params?: Record<string, any>; // e.g. { M: 16, efConstruction: 256 }
385
+ index_name?: string;
386
+ });
387
+
388
+ // Other index operations
389
+ await client.describeIndex({ collection_name, field_name? });
390
+ await client.listIndexes({ collection_name });
391
+ await client.getIndexStatistics({ collection_name, index_name? });
392
+ await client.dropIndex({ collection_name, field_name, index_name? });
393
+ await client.getIndexState({ collection_name, field_name? });
394
+ await client.getIndexBuildProgress({ collection_name, field_name? });
395
+ await client.alterIndexProperties({ collection_name, index_name, properties });
396
+ await client.dropIndexProperties({ collection_name, index_name, delete_keys: string[] });
397
+ ```
398
+
399
+ ---
400
+
401
+ ### Partition Management
402
+
403
+ ```typescript
404
+ await client.createPartition({ collection_name, partition_name });
405
+ await client.hasPartition({ collection_name, partition_name });
406
+ await client.listPartitions({ collection_name });
407
+ await client.loadPartitions({ collection_name, partition_names: string[] });
408
+ await client.releasePartitions({ collection_name, partition_names: string[] });
409
+ await client.dropPartition({ collection_name, partition_name });
410
+ ```
411
+
412
+ ---
413
+
414
+ ### Database Management
415
+
416
+ ```typescript
417
+ await client.createDatabase({ db_name });
418
+ await client.listDatabases();
419
+ await client.describeDatabase({ db_name });
420
+ await client.alterDatabaseProperties({ db_name, properties });
421
+ await client.dropDatabaseProperties({ db_name, delete_keys: string[] });
422
+ await client.dropDatabase({ db_name });
423
+ ```
424
+
425
+ ---
426
+
427
+ ### User & Role Management (RBAC)
428
+
429
+ ```typescript
430
+ // Users
431
+ await client.createUser({ username, password });
432
+ await client.updateUser({ username, oldPassword, newPassword });
433
+ await client.deleteUser({ username });
434
+ await client.listUsers();
435
+
436
+ // Roles
437
+ await client.createRole({ roleName });
438
+ await client.dropRole({ roleName });
439
+ await client.listRoles();
440
+ await client.addUserToRole({ username, roleName });
441
+ await client.removeUserFromRole({ username, roleName });
442
+
443
+ // Privileges
444
+ await client.grantPrivilege({ roleName, object, objectName, privilegeName });
445
+ await client.revokePrivilege({ roleName, object, objectName, privilegeName });
446
+ await client.listGrants({ roleName });
447
+
448
+ // V2 privilege API
449
+ await client.grantPrivilegeV2({ role, privilege, collection_name, db_name });
450
+ await client.revokePrivilegeV2({ role, privilege, collection_name, db_name });
451
+ ```
452
+
453
+ ---
454
+
455
+ ### Alias Management
456
+
457
+ ```typescript
458
+ await client.createAlias({ collection_name, alias });
459
+ await client.dropAlias({ alias });
460
+ await client.alterAlias({ collection_name, alias });
461
+ await client.describeAlias({ alias });
462
+ await client.listAliases({ collection_name });
463
+ ```
464
+
465
+ ---
466
+
467
+ ### Resource Group Management
468
+
469
+ ```typescript
470
+ await client.createResourceGroup({ resource_group, config });
471
+ await client.listResourceGroups();
472
+ await client.describeResourceGroup({ resource_group });
473
+ await client.dropResourceGroup({ resource_group });
474
+ await client.transferReplica({ source_resource_group, target_resource_group, collection_name, num_replica });
475
+ ```
476
+
477
+ ---
478
+
479
+ ### Bulk Import
480
+
481
+ #### BulkWriter — Generate import files offline
482
+
483
+ ```typescript
484
+ import { BulkWriter, DataType } from '@zilliz/milvus2-sdk-node';
485
+
486
+ const writer = new BulkWriter({
487
+ schema: {
488
+ fields: [
489
+ { name: 'id', data_type: DataType.Int64, is_primary_key: true },
490
+ { name: 'vector', data_type: DataType.FloatVector, dim: 128 },
491
+ { name: 'title', data_type: DataType.VarChar, max_length: 256 },
492
+ ],
493
+ },
494
+ format: 'parquet', // 'json' or 'parquet'
495
+ localPath: './bulk_data',
496
+ chunkSize: 128 * 1024 * 1024, // 128 MB per file
497
+ });
498
+
499
+ // Append rows
500
+ for (const row of rows) {
501
+ await writer.append(row);
502
+ }
503
+
504
+ // Finalize and get file paths
505
+ const batchFiles = await writer.close();
506
+ // batchFiles: [['./bulk_data/batch_0/1.parquet'], ...]
507
+ ```
508
+
509
+ #### Server-side import
510
+
511
+ ```typescript
512
+ // Trigger bulk import (files must be on Milvus-accessible storage)
513
+ await client.bulkInsert({ collection_name, files: ['data.json'] });
514
+
515
+ // Check import status
516
+ await client.getImportState({ taskId });
517
+ await client.listImportTasks({ collection_name });
518
+ ```
519
+
520
+ ---
521
+
522
+ ### Flush & Compaction
523
+
524
+ ```typescript
525
+ await client.flush({ collection_names: string[] });
526
+ await client.flushSync({ collection_names: string[] }); // Wait for completion
527
+ await client.flushAll(); // Flush all collections
528
+ await client.flushAllSync(); // Flush all and wait for completion
529
+ await client.compact({ collection_name });
530
+ await client.getCompactionState({ compactionID });
531
+ ```
532
+
533
+ ---
534
+
535
+ ### System Operations
536
+
537
+ ```typescript
538
+ await client.getVersion(); // Milvus server version
539
+ await client.checkHealth(); // Server health status
540
+ await client.reconnectToPrimary(); // Force reconnect to primary node
541
+ await client.runAnalyzer({ text, analyzer }); // Test text analyzer tokenization
542
+ ```
543
+
544
+ ---
545
+
546
+ ## Data Types
547
+
548
+ ### Scalar Types
549
+
550
+ | DataType enum | TypeScript value | Notes |
551
+ | -------------------- | ----------------- | ------------------------------------- |
552
+ | `DataType.Bool` | `boolean` | |
553
+ | `DataType.Int8` | `number` | |
554
+ | `DataType.Int16` | `number` | |
555
+ | `DataType.Int32` | `number` | |
556
+ | `DataType.Int64` | `number \| string` | Use string for values > 2^53 |
557
+ | `DataType.Float` | `number` | |
558
+ | `DataType.Double` | `number` | |
559
+ | `DataType.VarChar` | `string` | Requires `max_length` |
560
+ | `DataType.JSON` | `object` | |
561
+ | `DataType.Array` | `any[]` | Requires `element_type`, `max_capacity` |
562
+
563
+ ### Vector Types
564
+
565
+ | DataType enum | Data format | Field param |
566
+ | ---------------------------- | ---------------------------------- | ------------- |
567
+ | `DataType.FloatVector` | `number[]` | `dim: number` |
568
+ | `DataType.BinaryVector` | `number[]` (uint8 bytes) | `dim: number` |
569
+ | `DataType.Float16Vector` | `number[]` | `dim: number` |
570
+ | `DataType.BFloat16Vector` | `number[]` | `dim: number` |
571
+ | `DataType.Int8Vector` | `number[]` | `dim: number` |
572
+ | `DataType.SparseFloatVector` | `Record<number, number>` or array | no dim needed |
573
+
574
+ ### Field Definition
575
+
576
+ ```typescript
577
+ interface FieldType {
578
+ name: string;
579
+ data_type: DataType;
580
+ is_primary_key?: boolean;
581
+ autoID?: boolean;
582
+ dim?: number; // Required for vector types
583
+ max_length?: number; // Required for VarChar
584
+ element_type?: DataType; // Required for Array
585
+ max_capacity?: number; // Required for Array
586
+ default_value?: any;
587
+ is_partition_key?: boolean;
588
+ enable_analyzer?: boolean; // For full-text search
589
+ analyzer_params?: object;
590
+ }
591
+ ```
592
+
593
+ ---
594
+
595
+ ## Enums & Constants
596
+
597
+ ### MetricType
598
+
599
+ ```typescript
600
+ MetricType.L2 // Euclidean distance (smaller = more similar)
601
+ MetricType.IP // Inner product (larger = more similar)
602
+ MetricType.COSINE // Cosine similarity (larger = more similar)
603
+ MetricType.HAMMING // Hamming distance (binary vectors)
604
+ MetricType.JACCARD // Jaccard distance (binary vectors)
605
+ MetricType.BM25 // BM25 relevance (sparse/text)
606
+ ```
607
+
608
+ ### IndexType
609
+
610
+ ```typescript
611
+ IndexType.AUTOINDEX // Automatic selection (recommended)
612
+ IndexType.HNSW // High recall, in-memory
613
+ IndexType.IVF_FLAT // Balanced speed/recall
614
+ IndexType.IVF_SQ8 // Compressed IVF
615
+ IndexType.IVF_PQ // High compression IVF
616
+ IndexType.FLAT // Brute-force (exact)
617
+ IndexType.DISKANN // On-disk index
618
+ IndexType.BIN_FLAT // Binary brute-force
619
+ IndexType.BIN_IVF_FLAT // Binary IVF
620
+ IndexType.SPARSE_INVERTED_INDEX // Sparse vectors
621
+ IndexType.SPARSE_WAND // Sparse vectors (WAND)
622
+ ```
623
+
624
+ ### ConsistencyLevelEnum
625
+
626
+ ```typescript
627
+ ConsistencyLevelEnum.Strong // Read-after-write guarantee
628
+ ConsistencyLevelEnum.Session // Session-level consistency
629
+ ConsistencyLevelEnum.Bounded // Bounded staleness
630
+ ConsistencyLevelEnum.Eventually // Best performance
631
+ ```
632
+
633
+ ### ErrorCode
634
+
635
+ ```typescript
636
+ ErrorCode.SUCCESS // Operation succeeded
637
+ ErrorCode.UnexpectedError // Internal error
638
+ ErrorCode.CollectionNotExists // Collection not found
639
+ ErrorCode.IllegalArgument // Invalid argument
640
+ ErrorCode.RateLimit // Rate limited
641
+ ```
642
+
643
+ ---
644
+
645
+ ## Filter Expressions
646
+
647
+ Used in `search({ filter })`, `query({ filter })`, `delete({ filter })`.
648
+
649
+ ```
650
+ # Comparison
651
+ age > 18
652
+ price <= 99.9
653
+ status == "active"
654
+ name != "test"
655
+
656
+ # Logical operators
657
+ age > 18 AND status == "active"
658
+ price < 10 OR price > 100
659
+ NOT (status == "deleted")
660
+
661
+ # IN operator
662
+ id IN [1, 2, 3]
663
+ category IN ["books", "music"]
664
+
665
+ # String matching
666
+ title LIKE "hello%" # Starts with "hello"
667
+ title LIKE "%world" # Ends with "world"
668
+
669
+ # Array operations
670
+ ARRAY_CONTAINS(tags, "ai")
671
+ ARRAY_LENGTH(tags) > 3
672
+
673
+ # JSON field access
674
+ metadata["key"] == "value"
675
+ metadata["nested"]["field"] > 10
676
+
677
+ # Template expressions (parameterized)
678
+ await client.query({
679
+ collection_name: 'test',
680
+ filter: 'age > {min_age}',
681
+ filter_params: { min_age: 18 },
682
+ });
683
+ ```
684
+
685
+ ---
686
+
687
+ ## HTTP Client
688
+
689
+ For environments where gRPC is not available (Cloudflare Workers, Vercel Edge, AWS Lambda).
690
+
691
+ ```typescript
692
+ import { HttpClient } from '@zilliz/milvus2-sdk-node';
693
+
694
+ const client = new HttpClient({
695
+ endpoint: 'localhost:19530', // or Zilliz Cloud endpoint
696
+ username: 'root', // optional
697
+ password: 'milvus', // optional
698
+ token: 'your-api-key', // optional (for Zilliz Cloud)
699
+ database: 'default', // optional
700
+ timeout: 60000, // optional, ms
701
+ });
702
+
703
+ // Same API surface as MilvusClient for data operations
704
+ await client.createCollection({ ... });
705
+ await client.insert({ ... });
706
+ await client.search({ ... });
707
+ await client.query({ ... });
708
+ ```
709
+
710
+ ---
711
+
712
+ ## Error Handling
713
+
714
+ ```typescript
715
+ import { ErrorCode } from '@zilliz/milvus2-sdk-node';
716
+
717
+ try {
718
+ const res = await client.createCollection({ ... });
719
+ if (res.error_code !== ErrorCode.SUCCESS) {
720
+ console.error('Milvus error:', res.reason);
721
+ }
722
+ } catch (err) {
723
+ console.error('Connection/transport error:', err.message);
724
+ }
725
+ ```
726
+
727
+ ---
728
+
729
+ ## Common Patterns
730
+
731
+ ### Hybrid Search (vector + scalar filter)
732
+
733
+ ```typescript
734
+ const results = await client.search({
735
+ collection_name: 'products',
736
+ data: [queryVector],
737
+ limit: 20,
738
+ filter: 'category == "electronics" AND price < 500',
739
+ output_fields: ['name', 'price', 'category'],
740
+ });
741
+ ```
742
+
743
+ ### Dynamic Fields
744
+
745
+ ```typescript
746
+ // Enable dynamic fields on collection
747
+ await client.createCollection({
748
+ collection_name: 'flexible',
749
+ fields: [
750
+ { name: 'id', data_type: DataType.Int64, is_primary_key: true, autoID: true },
751
+ { name: 'vector', data_type: DataType.FloatVector, dim: 128 },
752
+ ],
753
+ enable_dynamic_field: true,
754
+ });
755
+
756
+ await client.loadCollection({ collection_name: 'flexible' });
757
+
758
+ // Insert with arbitrary fields — extra fields stored dynamically
759
+ await client.insert({
760
+ collection_name: 'flexible',
761
+ data: [
762
+ { vector: [...], color: 'red', score: 0.95 },
763
+ { vector: [...], color: 'blue', tags: ['a', 'b'] },
764
+ ],
765
+ });
766
+
767
+ // Query dynamic fields
768
+ await client.query({
769
+ collection_name: 'flexible',
770
+ filter: 'color == "red"',
771
+ output_fields: ['color', 'score'],
772
+ });
773
+ ```
774
+
775
+ ### Sparse Vector Search (e.g. BM25)
776
+
777
+ ```typescript
778
+ await client.createCollection({
779
+ collection_name: 'docs',
780
+ fields: [
781
+ { name: 'id', data_type: DataType.Int64, is_primary_key: true, autoID: true },
782
+ { name: 'sparse_vector', data_type: DataType.SparseFloatVector },
783
+ ],
784
+ });
785
+
786
+ await client.insert({
787
+ collection_name: 'docs',
788
+ data: [
789
+ { sparse_vector: { 0: 0.5, 10: 0.3, 200: 0.8 } }, // dict format
790
+ { sparse_vector: { 1: 0.1, 50: 0.9 } },
791
+ ],
792
+ });
793
+
794
+ await client.search({
795
+ collection_name: 'docs',
796
+ data: [{ 0: 0.5, 10: 0.3 }],
797
+ anns_field: 'sparse_vector',
798
+ limit: 10,
799
+ });
800
+ ```
801
+
802
+ ### Partition Key (auto-routing)
803
+
804
+ ```typescript
805
+ await client.createCollection({
806
+ collection_name: 'multi_tenant',
807
+ fields: [
808
+ { name: 'id', data_type: DataType.Int64, is_primary_key: true, autoID: true },
809
+ { name: 'tenant', data_type: DataType.VarChar, max_length: 64, is_partition_key: true },
810
+ { name: 'vector', data_type: DataType.FloatVector, dim: 128 },
811
+ ],
812
+ num_partitions: 16,
813
+ });
814
+
815
+ // Milvus automatically routes by partition key
816
+ await client.search({
817
+ collection_name: 'multi_tenant',
818
+ data: [queryVector],
819
+ filter: 'tenant == "user_123"', // Scoped to partition
820
+ limit: 10,
821
+ });
822
+ ```
823
+
824
+ ---
825
+
826
+ ### Advanced Features
827
+
828
+ For detailed guides on advanced features, visit the documentation:
55
829
 
56
- ## Contributing
830
+ - **[Hybrid Search](docs/content/operations/hybrid-search.mdx)** — Multi-vector search with reranking
831
+ - **[Full-Text Search](docs/content/advanced/full-text-search.mdx)** — BM25 keyword search with text analyzers
832
+ - **[Iterators](docs/content/operations/iterators.mdx)** — Paginate through large result sets
833
+ - **[Global Cluster](docs/content/advanced/global-cluster.mdx)** — Multi-region failover support
57
834
 
58
- 1. `yarn install`
59
- 2. Fetch milvus proto
60
- - `git submodule init` (if this is your first time)
61
- - `git submodule update --remote`
62
- 3. Add feature in milvus folder
63
- 4. Run test `yarn test -- test/Your-test-for-your-feature.spec.ts`
835
+ ---
64
836
 
65
837
  ## Links
66
838
 
67
- - [Documentation](https://milvus-io.github.io/milvus-sdk-node)
68
- - [Milvus Official Website](https://milvus.io/)
839
+ - [Full Documentation](https://milvus-io.github.io/milvus-sdk-node)
840
+ - [Milvus Documentation](https://milvus.io/docs)
69
841
  - [GitHub Repository](https://github.com/milvus-io/milvus-sdk-node)
842
+ - [Zilliz Cloud](https://cloud.zilliz.com/)
843
+ - [Examples](https://github.com/milvus-io/milvus-sdk-node/tree/main/examples)