@zilliz/milvus2-sdk-node 2.3.5 → 2.4.0

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 (121) hide show
  1. package/README.md +154 -35
  2. package/dist/milvus/HttpClient.d.ts +165 -2
  3. package/dist/milvus/HttpClient.js +17 -3
  4. package/dist/milvus/HttpClient.js.map +1 -1
  5. package/dist/milvus/MilvusClient.d.ts +3 -3
  6. package/dist/milvus/MilvusClient.js +42 -8
  7. package/dist/milvus/MilvusClient.js.map +1 -1
  8. package/dist/milvus/const/client.d.ts +4 -3
  9. package/dist/milvus/const/client.js +4 -3
  10. package/dist/milvus/const/client.js.map +1 -1
  11. package/dist/milvus/const/defaults.d.ts +5 -4
  12. package/dist/milvus/const/defaults.js +14 -13
  13. package/dist/milvus/const/defaults.js.map +1 -1
  14. package/dist/milvus/const/error.js +1 -1
  15. package/dist/milvus/const/error.js.map +1 -1
  16. package/dist/milvus/const/milvus.d.ts +47 -8
  17. package/dist/milvus/const/milvus.js +42 -3
  18. package/dist/milvus/const/milvus.js.map +1 -1
  19. package/dist/milvus/grpc/BaseClient.d.ts +11 -9
  20. package/dist/milvus/grpc/BaseClient.js +59 -21
  21. package/dist/milvus/grpc/BaseClient.js.map +1 -1
  22. package/dist/milvus/grpc/Collection.d.ts +311 -366
  23. package/dist/milvus/grpc/Collection.js +355 -387
  24. package/dist/milvus/grpc/Collection.js.map +1 -1
  25. package/dist/milvus/grpc/Data.d.ts +244 -291
  26. package/dist/milvus/grpc/Data.js +402 -539
  27. package/dist/milvus/grpc/Data.js.map +1 -1
  28. package/dist/milvus/grpc/Database.d.ts +29 -41
  29. package/dist/milvus/grpc/Database.js +32 -44
  30. package/dist/milvus/grpc/Database.js.map +1 -1
  31. package/dist/milvus/grpc/GrpcClient.d.ts +34 -13
  32. package/dist/milvus/grpc/GrpcClient.js +80 -70
  33. package/dist/milvus/grpc/GrpcClient.js.map +1 -1
  34. package/dist/milvus/grpc/MilvusIndex.d.ts +127 -67
  35. package/dist/milvus/grpc/MilvusIndex.js +166 -70
  36. package/dist/milvus/grpc/MilvusIndex.js.map +1 -1
  37. package/dist/milvus/grpc/Partition.d.ts +78 -113
  38. package/dist/milvus/grpc/Partition.js +109 -119
  39. package/dist/milvus/grpc/Partition.js.map +1 -1
  40. package/dist/milvus/grpc/Resource.d.ts +63 -92
  41. package/dist/milvus/grpc/Resource.js +69 -98
  42. package/dist/milvus/grpc/Resource.js.map +1 -1
  43. package/dist/milvus/grpc/User.d.ts +263 -295
  44. package/dist/milvus/grpc/User.js +287 -310
  45. package/dist/milvus/grpc/User.js.map +1 -1
  46. package/dist/milvus/http/Alias.d.ts +37 -0
  47. package/dist/milvus/http/Alias.js +62 -0
  48. package/dist/milvus/http/Alias.js.map +1 -0
  49. package/dist/milvus/http/Collection.d.ts +15 -1
  50. package/dist/milvus/http/Collection.js +55 -9
  51. package/dist/milvus/http/Collection.js.map +1 -1
  52. package/dist/milvus/http/Import.d.ts +33 -0
  53. package/dist/milvus/http/Import.js +48 -0
  54. package/dist/milvus/http/Import.js.map +1 -0
  55. package/dist/milvus/http/MilvusIndex.d.ts +35 -0
  56. package/dist/milvus/http/MilvusIndex.js +55 -0
  57. package/dist/milvus/http/MilvusIndex.js.map +1 -0
  58. package/dist/milvus/http/Partition.d.ts +41 -0
  59. package/dist/milvus/http/Partition.js +76 -0
  60. package/dist/milvus/http/Partition.js.map +1 -0
  61. package/dist/milvus/http/Role.d.ts +39 -0
  62. package/dist/milvus/http/Role.js +69 -0
  63. package/dist/milvus/http/Role.js.map +1 -0
  64. package/dist/milvus/http/User.d.ts +41 -0
  65. package/dist/milvus/http/User.js +76 -0
  66. package/dist/milvus/http/User.js.map +1 -0
  67. package/dist/milvus/http/Vector.d.ts +5 -3
  68. package/dist/milvus/http/Vector.js +10 -7
  69. package/dist/milvus/http/Vector.js.map +1 -1
  70. package/dist/milvus/http/index.d.ts +6 -0
  71. package/dist/milvus/http/index.js +6 -0
  72. package/dist/milvus/http/index.js.map +1 -1
  73. package/dist/milvus/index.d.ts +0 -1
  74. package/dist/milvus/index.js +0 -1
  75. package/dist/milvus/index.js.map +1 -1
  76. package/dist/milvus/types/Client.d.ts +5 -0
  77. package/dist/milvus/types/Collection.d.ts +34 -9
  78. package/dist/milvus/types/Common.d.ts +1 -3
  79. package/dist/milvus/types/Data.d.ts +79 -23
  80. package/dist/milvus/types/Data.js +1 -0
  81. package/dist/milvus/types/Data.js.map +1 -1
  82. package/dist/milvus/types/HighLevel.d.ts +6 -3
  83. package/dist/milvus/types/Http.d.ts +191 -9
  84. package/dist/milvus/types/MilvusIndex.d.ts +17 -3
  85. package/dist/milvus/utils/Bytes.d.ts +84 -0
  86. package/dist/milvus/utils/Bytes.js +261 -0
  87. package/dist/milvus/utils/Bytes.js.map +1 -0
  88. package/dist/milvus/utils/Format.d.ts +126 -68
  89. package/dist/milvus/utils/Format.js +375 -94
  90. package/dist/milvus/utils/Format.js.map +1 -1
  91. package/dist/milvus/utils/Function.d.ts +4 -2
  92. package/dist/milvus/utils/Function.js +58 -25
  93. package/dist/milvus/utils/Function.js.map +1 -1
  94. package/dist/milvus/utils/Grpc.d.ts +3 -2
  95. package/dist/milvus/utils/Grpc.js +65 -98
  96. package/dist/milvus/utils/Grpc.js.map +1 -1
  97. package/dist/milvus/utils/Validate.d.ts +18 -3
  98. package/dist/milvus/utils/Validate.js +38 -12
  99. package/dist/milvus/utils/Validate.js.map +1 -1
  100. package/dist/milvus/utils/index.d.ts +1 -1
  101. package/dist/milvus/utils/index.js +1 -1
  102. package/dist/milvus/utils/index.js.map +1 -1
  103. package/dist/proto/proto/common.proto +26 -1
  104. package/dist/proto/proto/google/protobuf/descriptor.proto +90 -28
  105. package/dist/proto/proto/milvus.proto +168 -2
  106. package/dist/proto/proto/rg.proto +28 -0
  107. package/dist/proto/proto/schema.proto +34 -0
  108. package/dist/sdk.json +1 -1
  109. package/package.json +8 -5
  110. package/dist/milvus/OrmClient.d.ts +0 -19
  111. package/dist/milvus/OrmClient.js +0 -51
  112. package/dist/milvus/OrmClient.js.map +0 -1
  113. package/dist/milvus/orm/Collection.d.ts +0 -43
  114. package/dist/milvus/orm/Collection.js +0 -165
  115. package/dist/milvus/orm/Collection.js.map +0 -1
  116. package/dist/milvus/orm/index.d.ts +0 -1
  117. package/dist/milvus/orm/index.js +0 -18
  118. package/dist/milvus/orm/index.js.map +0 -1
  119. package/dist/milvus/utils/Blob.d.ts +0 -4
  120. package/dist/milvus/utils/Blob.js +0 -18
  121. package/dist/milvus/utils/Blob.js.map +0 -1
@@ -15,31 +15,29 @@ const Collection_1 = require("./Collection");
15
15
  class Data extends Collection_1.Collection {
16
16
  constructor() {
17
17
  super(...arguments);
18
- // vectorTypes
19
- this.vectorTypes = [__1.DataType.BinaryVector, __1.DataType.FloatVector];
18
+ // alias
19
+ this.hybridSearch = this.search;
20
20
  /**
21
- * list indexed segments
21
+ * List indexed segments.
22
22
  *
23
- * @param data
24
- * | Property | Type | Description |
25
- * | :-- | :-- | :-- |
26
- * | collection_name | string | the name of the collection |
27
- * | index_name | string | the name of the collection's index |
28
- * | timeout? | number | An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined |
23
+ * @param {ListIndexedSegmentReq} data - The request parameters.
24
+ * @param {string} data.collection_name - The name of the collection.
25
+ * @param {string} data.index_name - The name of the collection's index.
26
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined.
29
27
  *
30
- * @returns
31
- * | Property | Description |
32
- * | :-- | :-- |
33
- * | status | status |
34
- * | segmentIDs | segment IDs |
28
+ * @returns {Promise<ListIndexedSegmentResponse>} The result of the operation.
29
+ * @returns {string} status.error_code - The error code of the operation.
30
+ * @returns {string} status.reason - The reason for the error, if any.
31
+ * @returns {number[]} segmentIDs - Segment IDs.
35
32
  *
36
33
  * @throws {Error} if `collection_name` property is not present in `data`
37
34
  *
38
- * #### Example
39
- *
35
+ * @example
40
36
  * ```
41
- * new milvusClient(MILUVS_ADDRESS).getPkFieldName({
37
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
38
+ * const indexedSegments = await milvusClient.listIndexedSegment({
42
39
  * collection_name: 'my_collection',
40
+ * index_name: 'my_index',
43
41
  * });
44
42
  * ```
45
43
  */
@@ -50,7 +48,7 @@ class Data extends Collection_1.Collection {
50
48
  // throw new Error(ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
51
49
  // }
52
50
  // const res = await promisify(
53
- // this.client,
51
+ // this.channelPool,
54
52
  // 'ListIndexedSegment',
55
53
  // data,
56
54
  // data.timeout || this.timeout
@@ -58,28 +56,26 @@ class Data extends Collection_1.Collection {
58
56
  // return res;
59
57
  // }
60
58
  /**
61
- * describe segment index data
59
+ * Describe segment index data.
62
60
  *
63
- * @param data
64
- * | Property | Type | Description |
65
- * | :-- | :-- | :-- |
66
- * | collection_name | string | the name of the collection |
67
- * | segmentsIDs | number[] | the name of the collection's index |
68
- * | timeout? | number | An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined |
61
+ * @param {DescribeSegmentIndexDataReq} data - The request parameters.
62
+ * @param {string} data.collection_name - The name of the collection.
63
+ * @param {number[]} data.segmentsIDs - The segment IDs.
64
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined.
69
65
  *
70
- * @returns
71
- * | Property | Description |
72
- * | :-- | :-- |
73
- * | status | status |
74
- * | segmentIDs | segment IDs |
66
+ * @returns {Promise<DescribeSegmentIndexDataResponse>} The result of the operation.
67
+ * @returns {string} status.error_code - The error code of the operation.
68
+ * @returns {string} status.reason - The reason for the error, if any.
69
+ * @returns {number[]} segmentIDs - Segment IDs.
75
70
  *
76
71
  * @throws {Error} if `collection_name` property is not present in `data`
77
72
  *
78
- * #### Example
79
- *
73
+ * @example
80
74
  * ```
81
- * new milvusClient(MILUVS_ADDRESS).getPkFieldName({
75
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
76
+ * const segmentIndexData = await milvusClient.describeSegmentIndexData({
82
77
  * collection_name: 'my_collection',
78
+ * segmentsIDs: [1,2,3,4],
83
79
  * });
84
80
  * ```
85
81
  */
@@ -90,7 +86,7 @@ class Data extends Collection_1.Collection {
90
86
  // throw new Error(ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
91
87
  // }
92
88
  // const res = await promisify(
93
- // this.client,
89
+ // this.channelPool,
94
90
  // 'DescribeSegmentIndexData',
95
91
  // data,
96
92
  // data.timeout || this.timeout
@@ -115,31 +111,27 @@ class Data extends Collection_1.Collection {
115
111
  });
116
112
  }
117
113
  /**
118
- * Insert/upsert data into Milvus.
119
- *
120
- * @param data
121
- * | Property | Type | Description |
122
- * | :--- | :-- | :-- |
123
- * | collection_name | String | Collection name |
124
- * | partition_name(optional)| String | Partition name |
125
- * | fields_data or data | { [x: string]: any }[] | If the field type is binary, the vector data length needs to be dimension / 8 |
126
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
127
-
128
- *
129
- * @returns
130
- * | Property | Description |
131
- * | :-- | :-- |
132
- * | status | { error_code: number, reason: string } |
133
- * | succ_index | Index array of the successfully inserted data |
134
- * | err_index | Index array of the unsuccessfully inserted data |
135
- * | IDs | ID array of the successfully inserted data |
136
- *
137
- *
138
- * #### Example
139
- *
114
+ * Insert or upsert data into a Milvus collection.
115
+ *
116
+ * @param {InsertReq} data - The request parameters.
117
+ * @param {string} data.collection_name - The name of the collection.
118
+ * @param {string} [data.partition_name] - The name of the partition (optional).
119
+ * @param {{ [x: string]: any }[]} data.data - The data to be inserted. If the field type is binary, the vector data length needs to be dimension / 8.
120
+ * @param {InsertTransformers} data.transformers - The transformers for bf16 or f16 data, it accept an f32 array, it should output f16 or bf16 bytes (optional)
121
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
122
+ *
123
+ * @returns {Promise<MutationResult>} The result of the operation.
124
+ * @returns {string} status.error_code - The error code of the operation.
125
+ * @returns {string} status.reason - The reason for the error, if any.
126
+ * @returns {number[]} succ_index - Index array of the successfully inserted data.
127
+ * @returns {number[]} err_index - Index array of the unsuccessfully inserted data.
128
+ * @returns {number[]} IDs - ID array of the successfully inserted data.
129
+ *
130
+ * @example
140
131
  * ```
141
- * new milvusClient(MILUVS_ADDRESS).insert({
142
- * collection_name: COLLECTION_NAME,
132
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
133
+ * const resStatus = await milvusClient.insert({
134
+ * collection_name: 'my_collection',
143
135
  * fields_data: [{
144
136
  * vector_field: [1,2,2,4],
145
137
  * scalar_field: 1
@@ -213,7 +205,7 @@ class Data extends Collection_1.Collection {
213
205
  field.data = field.data.concat((0, __1.buildFieldData)(rowData, field));
214
206
  break;
215
207
  default:
216
- field.data[rowIndex] = (0, __1.buildFieldData)(rowData, field);
208
+ field.data[rowIndex] = (0, __1.buildFieldData)(rowData, field, data.transformers);
217
209
  break;
218
210
  }
219
211
  });
@@ -225,78 +217,105 @@ class Data extends Collection_1.Collection {
225
217
  // milvus return string for field type, so we define the DataTypeMap to the value we need.
226
218
  // but if milvus change the string, may cause we cant find value.
227
219
  const type = __1.DataTypeMap[field.type];
228
- const key = this.vectorTypes.includes(type) ? 'vectors' : 'scalars';
220
+ const key = __1.VectorDataTypes.includes(type) ? 'vectors' : 'scalars';
229
221
  const dataKey = (0, __1.getDataKey)(type);
230
222
  const elementType = __1.DataTypeMap[field.elementType];
231
223
  const elementTypeKey = (0, __1.getDataKey)(elementType);
232
- return {
233
- type,
234
- field_name: field.name,
235
- is_dynamic: field.name === __1.DEFAULT_DYNAMIC_FIELD,
236
- [key]: type === __1.DataType.FloatVector
237
- ? {
224
+ // build key value
225
+ let keyValue;
226
+ switch (type) {
227
+ case __1.DataType.FloatVector:
228
+ keyValue = {
238
229
  dim: field.dim,
239
230
  [dataKey]: {
240
231
  data: field.data,
241
232
  },
242
- }
243
- : type === __1.DataType.BinaryVector
244
- ? {
245
- dim: field.dim,
246
- [dataKey]: (0, __1.parseBinaryVectorToBytes)(field.data),
247
- }
248
- : type === __1.DataType.Array
249
- ? {
250
- [dataKey]: {
251
- data: field.data.map(d => {
252
- return {
253
- [elementTypeKey]: {
254
- type: elementType,
255
- data: d,
256
- },
257
- };
258
- }),
259
- element_type: elementType,
260
- },
261
- }
262
- : {
263
- [dataKey]: {
264
- data: field.data,
265
- },
266
- },
233
+ };
234
+ break;
235
+ case __1.DataType.BFloat16Vector:
236
+ case __1.DataType.Float16Vector:
237
+ keyValue = {
238
+ dim: field.dim,
239
+ [dataKey]: Buffer.concat(field.data),
240
+ };
241
+ break;
242
+ case __1.DataType.BinaryVector:
243
+ keyValue = {
244
+ dim: field.dim,
245
+ [dataKey]: (0, __1.f32ArrayToBinaryBytes)(field.data),
246
+ };
247
+ break;
248
+ case __1.DataType.SparseFloatVector:
249
+ const dim = (0, __1.getSparseDim)(field.data);
250
+ keyValue = {
251
+ dim,
252
+ [dataKey]: {
253
+ dim,
254
+ contents: (0, __1.sparseRowsToBytes)(field.data),
255
+ },
256
+ };
257
+ break;
258
+ case __1.DataType.Array:
259
+ keyValue = {
260
+ [dataKey]: {
261
+ data: field.data.map(d => {
262
+ return {
263
+ [elementTypeKey]: {
264
+ type: elementType,
265
+ data: d,
266
+ },
267
+ };
268
+ }),
269
+ element_type: elementType,
270
+ },
271
+ };
272
+ break;
273
+ default:
274
+ keyValue = {
275
+ [dataKey]: {
276
+ data: field.data,
277
+ },
278
+ };
279
+ break;
280
+ }
281
+ return {
282
+ type,
283
+ field_name: field.name,
284
+ is_dynamic: field.name === __1.DEFAULT_DYNAMIC_FIELD,
285
+ [key]: keyValue,
267
286
  };
268
287
  });
269
288
  // if timeout is not defined, set timeout to 0
270
289
  const timeout = typeof data.timeout === 'undefined' ? 0 : data.timeout;
290
+ // delete data
291
+ try {
292
+ delete params.data;
293
+ }
294
+ catch (e) { }
271
295
  // execute Insert
272
- const promise = yield (0, __1.promisify)(this.client, upsert ? 'Upsert' : 'Insert', params, timeout);
296
+ const promise = yield (0, __1.promisify)(this.channelPool, upsert ? 'Upsert' : 'Insert', params, timeout);
273
297
  return promise;
274
298
  });
275
299
  }
276
300
  /**
277
- * Delete entities in Milvus
301
+ * Delete entities in a Milvus collection.
278
302
  *
279
- * @param data
280
- * | Property | Type | Description |
281
- * | :--- | :-- | :-- |
282
- * | collection_name | String | Collection name |
283
- * | partition_name(optional)| String | Partition name |
284
- * | expr or filter | String | Boolean expression used to filter attribute. |
285
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
286
-
287
- *
288
- * @returns
289
- * | Property | Description |
290
- * | :-- | :-- |
291
- * | status | { error_code: number, reason: string } |
292
- * | IDs | ID array of the successfully deleted data |
303
+ * @param {DeleteEntitiesReq} data - The request parameters.
304
+ * @param {string} data.collection_name - The name of the collection.
305
+ * @param {string} [data.partition_name] - The name of the partition (optional).
306
+ * @param {string} data.expr - Boolean expression used to filter entities for deletion.
307
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
293
308
  *
309
+ * @returns {Promise<MutationResult>} The result of the operation.
310
+ * @returns {string} status.error_code - The error code of the operation.
311
+ * @returns {string} status.reason - The reason for the error, if any.
312
+ * @returns {number[]} IDs - ID array of the successfully deleted data.
294
313
  *
295
- * #### Example
296
- *
314
+ * @example
297
315
  * ```
298
- * new milvusClient(MILUVS_ADDRESS).deleteEntities({
299
- * collection_name: COLLECTION_NAME,
316
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
317
+ * const resStatus = await milvusClient.deleteEntities({
318
+ * collection_name: 'my_collection',
300
319
  * expr: 'id in [1,2,3,4]'
301
320
  * });
302
321
  * ```
@@ -312,35 +331,40 @@ class Data extends Collection_1.Collection {
312
331
  }
313
332
  // filter > expr
314
333
  data.expr = data.filter || data.expr;
315
- const promise = yield (0, __1.promisify)(this.client, 'Delete', data, data.timeout || this.timeout);
334
+ const promise = yield (0, __1.promisify)(this.channelPool, 'Delete', data, data.timeout || this.timeout);
316
335
  return promise;
317
336
  });
318
337
  }
319
338
  /**
320
- * Delete entities in Milvus
321
- *
322
- * @param data
323
- * | Property | Type | Description |
324
- * | :--- | :-- | :-- |
325
- * | collection_name | String | Collection name |
326
- * | partition_name(optional)| String | Partition name |
327
- * | ids | String[] or Number[] | ids to delete |
328
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
329
-
330
- *
331
- * @returns
332
- * | Property | Description |
333
- * | :-- | :-- |
334
- * | status | { error_code: number, reason: string } |
335
- * | IDs | ID array of the successfully deleted data |
336
- *
337
- *
338
- * #### Example
339
+ * Delete entities in a Milvus collection.
340
+ *
341
+ * @param {DeleteReq} data - The request parameters.
342
+ * @param {string} data.collection_name - The name of the collection.
343
+ * @param {string} [data.partition_name] - The name of the partition (optional).
344
+ * @param {(string[] | number[])} [data.ids] - IDs of the entities to delete.
345
+ * @param {string} [data.filter] - Filter expression, takes precedence over ids.
346
+ * @param {string} [data.expr] - equals to data.filter.
347
+ * @param {number} [data.timeout] - Optional duration of time in milliseconds to allow for the RPC. If undefined, the client keeps waiting until the server responds or an error occurs. Default is undefined.
348
+ *
349
+ * @returns {Promise<MutationResult>} The result of the operation.
350
+ * @returns {string} status.error_code - The error code of the operation.
351
+ * @returns {string} status.reason - The reason for the error, if any.
352
+ * @returns {number[]} IDs - Array of IDs of the successfully deleted entities.
353
+ *
354
+ * @example
355
+ * ```
356
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
357
+ * const resStatus = await milvusClient.delete({
358
+ * collection_name: 'my_collection',
359
+ * filter: 'id in [1,2,3,4]'
360
+ * });
361
+ * ```
339
362
  *
340
363
  * ```
341
- * new milvusClient(MILUVS_ADDRESS).deleteEntities({
342
- * collection_name: COLLECTION_NAME,
343
- * expr: 'id in [1,2,3,4]'
364
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
365
+ * const resStatus = await milvusClient.delete({
366
+ * collection_name: 'my_collection',
367
+ * ids: [1,2,3,4]
344
368
  * });
345
369
  * ```
346
370
  */
@@ -349,229 +373,104 @@ class Data extends Collection_1.Collection {
349
373
  if (!data || !data.collection_name) {
350
374
  throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
351
375
  }
352
- if (!data.ids || data.ids.length === 0) {
353
- throw new Error(__1.ERROR_REASONS.IDS_REQUIRED);
354
- }
355
376
  const pkField = yield this.getPkFieldName(data);
356
377
  const pkFieldType = yield this.getPkFieldType(data);
378
+ let expr = '';
357
379
  // generate expr by different type of pk
358
- const expr = __1.DataTypeMap[pkFieldType] === __1.DataType.VarChar
359
- ? `${pkField} in ["${data.ids.join('","')}"]`
360
- : `${pkField} in [${data.ids.join(',')}]`;
380
+ if (data.ids) {
381
+ expr =
382
+ __1.DataTypeMap[pkFieldType] === __1.DataType.VarChar
383
+ ? `${pkField} in ["${data.ids.join('","')}"]`
384
+ : `${pkField} in [${data.ids.join(',')}]`;
385
+ }
386
+ // if filter exist use filter;
387
+ if (data.filter) {
388
+ expr = data.filter;
389
+ }
361
390
  const req = Object.assign(Object.assign({}, data), { expr });
362
391
  return this.deleteEntities(req);
363
392
  });
364
393
  }
365
394
  /**
366
- * Perform vector similarity search.
367
- *
368
- * @param data
369
- * | Property | Type | Description |
370
- * | :--- | :-- | :-- |
371
- * | collection_name | String | Collection name |
372
- * | vectors or data or (vector) | Number[][] or Number[] | Original vector to search with |
373
- * | partition_names(optional)| String[] | Array of partition names |
374
- * | limit(optional) | number | topk alias |
375
- * | topk(optional) | number | topk |
376
- * | offset(optional) | number | offset |
377
- * | filter(optional) | String | Scalar field filter expression |
378
- * | expr(optional) | String | filter alias |
379
- * | output_fields(optional) | String[] | Support scalar field |
380
- * | metric_type(optional) | String | similarity metric |
381
- * | params(optional) | key value object | search params |
382
- *
383
- * @returns
384
- * | Property | Description |
385
- * | :-- | :-- |
386
- * | status | { error_code: number, reason: string } |∂
387
- * | results | {score:number,id:string}[]; |
388
- *
389
- * #### Example
390
- *
395
+ * Perform vector similarity search in a Milvus collection.
396
+ *
397
+ * @param {SearchReq | SearchSimpleReq} data - The request parameters.
398
+ * @param {string} data.collection_name - The name of the collection.
399
+ * @param {Number[]} data.vector - Original vector to search with.
400
+ * @param {string[]} [data.partition_names] - Array of partition names (optional).
401
+ * @param {number} [data.topk] - Topk (optional).
402
+ * @param {number} [data.limit] - Alias for topk (optional).
403
+ * @param {number} [data.offset] - Offset (optional).
404
+ * @param {string} [data.filter] - Scalar field filter expression (optional).
405
+ * @param {string[]} [data.output_fields] - Support scalar field (optional).
406
+ * @param {object} [data.params] - Search params (optional).
407
+ * @param {OutputTransformers} data.transformers - The transformers for bf16 or f16 data, it accept bytes or sparse dic vector, it can ouput f32 array or other format(optional)
408
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
409
+ *
410
+ * @returns {Promise<SearchResults>} The result of the operation.
411
+ * @returns {string} status.error_code - The error code of the operation.
412
+ * @returns {string} status.reason - The reason for the error, if any.
413
+ * @returns {{score:number,id:string, [outputfield]: value}[]} results - Array of search results.
414
+ *
415
+ * @example
391
416
  * ```
392
- * new milvusClient(MILUVS_ADDRESS).search({
393
- * collection_name: COLLECTION_NAME,
394
- * vector: [1, 2, 3, 4],
417
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
418
+ * const searchResults = await milvusClient.search({
419
+ * collection_name: 'my_collection',
420
+ * vector: [1, 2, 3, 4],
395
421
  * });
396
422
  * ```
397
423
  */
398
424
  search(data) {
399
- var _a, _b, _c, _d;
400
425
  return __awaiter(this, void 0, void 0, function* () {
401
- // params check
402
- (0, __1.checkSearchParams)(data);
403
- try {
404
- // get collection info
405
- const collectionInfo = yield this.describeCollection({
406
- collection_name: data.collection_name,
407
- cache: true,
408
- });
409
- // get information from collection info
410
- let vectorType;
411
- let defaultOutputFields = [];
412
- let anns_field;
413
- for (let i = 0; i < collectionInfo.schema.fields.length; i++) {
414
- const f = collectionInfo.schema.fields[i];
415
- const type = __1.DataTypeMap[f.data_type];
416
- // filter vector field
417
- if (type === __1.DataType.FloatVector || type === __1.DataType.BinaryVector) {
418
- // anns field
419
- anns_field = f.name;
420
- // vector type
421
- vectorType = type;
422
- }
423
- else {
424
- // save field name
425
- defaultOutputFields.push(f.name);
426
- }
427
- }
428
- // create search params
429
- const search_params = data.search_params || {
430
- anns_field: anns_field,
431
- topk: data.limit ||
432
- data.topk ||
433
- __1.DEFAULT_TOPK,
434
- offset: data.offset || 0,
435
- metric_type: data.metric_type || '',
436
- params: JSON.stringify(data.params || {}),
437
- ignore_growing: data.ignore_growing || false,
438
- };
439
- // create search vectors
440
- let searchVectors = data.vectors ||
441
- data.data ||
442
- data.vector;
443
- // make sure the searchVectors format is correct
444
- if (!Array.isArray(searchVectors[0])) {
445
- searchVectors = [searchVectors];
446
- }
447
- /**
448
- * It will decide the score precision.
449
- * If round_decimal is 3, need return like 3.142
450
- * And if Milvus return like 3.142, Node will add more number after this like 3.142000047683716.
451
- * So the score need to slice by round_decimal
452
- */
453
- const round_decimal = (_b = (_a = data.search_params) === null || _a === void 0 ? void 0 : _a.round_decimal) !== null && _b !== void 0 ? _b : (_c = data.params) === null || _c === void 0 ? void 0 : _c.round_decimal;
454
- // create placeholder_group
455
- const PlaceholderGroup = this.milvusProto.lookupType('milvus.proto.common.PlaceholderGroup');
456
- // tag $0 is hard code in milvus, when dsltype is expr
457
- const placeholderGroupBytes = PlaceholderGroup.encode(PlaceholderGroup.create({
458
- placeholders: [
459
- {
460
- tag: '$0',
461
- type: vectorType,
462
- values: searchVectors.map(v => vectorType === __1.DataType.BinaryVector
463
- ? (0, __1.parseBinaryVectorToBytes)(v)
464
- : (0, __1.parseFloatVectorToBytes)(v)),
465
- },
466
- ],
467
- })).finish();
468
- const promise = yield (0, __1.promisify)(this.client, 'Search', {
469
- collection_name: data.collection_name,
470
- partition_names: data.partition_names,
471
- output_fields: data.output_fields || defaultOutputFields,
472
- nq: data.nq || searchVectors.length,
473
- dsl: data.expr || data.filter || '',
474
- dsl_type: __1.DslType.BoolExprV1,
475
- placeholder_group: placeholderGroupBytes,
476
- search_params: (0, __1.parseToKeyValue)(search_params),
477
- consistency_level: typeof data.consistency_level === 'undefined'
478
- ? __1.ConsistencyLevelEnum.Bounded
479
- : data.consistency_level,
480
- }, data.timeout || this.timeout);
481
- // if search failed
482
- // if nothing returned
483
- // return empty with status
484
- if (promise.status.error_code !== __1.ErrorCode.SUCCESS ||
485
- promise.results.scores.length === 0) {
486
- return {
487
- status: promise.status,
488
- results: [],
489
- };
490
- }
491
- // build final results array
492
- const results = [];
493
- const { topks, scores, fields_data, ids } = promise.results;
494
- // build fields data map
495
- const fieldsDataMap = (0, __1.buildFieldDataMap)(fields_data);
496
- // build output name array
497
- const output_fields = [
498
- 'id',
499
- ...(!!((_d = promise.results.output_fields) === null || _d === void 0 ? void 0 : _d.length)
500
- ? promise.results.output_fields
501
- : fields_data.map(f => f.field_name)),
502
- ];
503
- // vector id support int / str id.
504
- const idData = ids ? ids[ids.id_field].data : {};
505
- // add id column
506
- fieldsDataMap.set('id', idData);
507
- // fieldsDataMap.set('score', scores); TODO: fieldDataMap to support formatter
508
- /**
509
- * This code block formats the search results returned by Milvus into row data for easier use.
510
- * Milvus supports multiple queries to search and returns all columns data, so we need to splice the data for each search result using the `topk` variable.
511
- * The `topk` variable is the key we use to splice data for every search result.
512
- * The `scores` array is spliced using the `topk` value, and the resulting scores are formatted to the specified precision using the `formatNumberPrecision` function. The resulting row data is then pushed to the `results` array.
513
- */
514
- topks.forEach((v, index) => {
515
- const topk = Number(v);
516
- scores.splice(0, topk).forEach((score, scoreIndex) => {
517
- // get correct index
518
- const i = index === 0 ? scoreIndex : scoreIndex + topk * index;
519
- // fix round_decimal
520
- const fixedScore = typeof round_decimal === 'undefined' || round_decimal === -1
521
- ? score
522
- : (0, __1.formatNumberPrecision)(score, round_decimal);
523
- // init result object
524
- const result = { score: fixedScore };
525
- // build result,
526
- output_fields.forEach(field_name => {
527
- // Check if the field_name exists in the fieldsDataMap
528
- const isFixedSchema = fieldsDataMap.has(field_name);
529
- // Get the data for the field_name from the fieldsDataMap
530
- // If the field_name is not in the fieldsDataMap, use the DEFAULT_DYNAMIC_FIELD
531
- const data = fieldsDataMap.get(isFixedSchema ? field_name : __1.DEFAULT_DYNAMIC_FIELD);
532
- // make dynamic data[i] safe
533
- data[i] = isFixedSchema ? data[i] : data[i] || {};
534
- // extract dynamic info from dynamic field if necessary
535
- result[field_name] = isFixedSchema ? data[i] : data[i][field_name];
536
- });
537
- // init result slot
538
- results[index] = results[index] || [];
539
- // push result data
540
- results[index].push(result);
541
- });
542
- });
426
+ // get collection info
427
+ const collectionInfo = yield this.describeCollection({
428
+ collection_name: data.collection_name,
429
+ cache: true,
430
+ });
431
+ // build search params
432
+ const { request, nq, round_decimal, isHybridSearch } = (0, __1.buildSearchRequest)(data, collectionInfo, this.milvusProto);
433
+ // execute search
434
+ const originSearchResult = yield (0, __1.promisify)(this.channelPool, isHybridSearch ? 'HybridSearch' : 'Search', request, data.timeout || this.timeout);
435
+ // if search failed
436
+ // if nothing returned
437
+ // return empty with status
438
+ if (originSearchResult.status.error_code !== __1.ErrorCode.SUCCESS ||
439
+ originSearchResult.results.scores.length === 0) {
543
440
  return {
544
- status: promise.status,
545
- // if only searching 1 vector, return the first object of results array
546
- results: searchVectors.length === 1 ? results[0] || [] : results,
441
+ status: originSearchResult.status,
442
+ results: [],
547
443
  };
548
444
  }
549
- catch (err) {
550
- /* istanbul ignore next */
551
- throw new Error(err);
552
- }
445
+ // build final results array
446
+ const results = (0, __1.formatSearchResult)(originSearchResult, {
447
+ round_decimal,
448
+ transformers: data.transformers,
449
+ });
450
+ return {
451
+ status: originSearchResult.status,
452
+ // nq === 1, return the first object of results array
453
+ results: nq === 1 ? results[0] || [] : results,
454
+ };
553
455
  });
554
456
  }
555
457
  /**
556
- * Milvus temporarily buffers the newly inserted vectors in the cache. Call `flush()` to persist them to the object storage.
557
- * It's async function, so it's will take some times to execute.
558
- * @param data
559
- * | Property | Type | Description |
560
- * | :--- | :-- | :-- |
561
- * | collection_names | String[] | Array of collection names |
562
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
563
-
458
+ * Flushes the newly inserted vectors that are temporarily buffered in the cache to the object storage.
459
+ * This is an asynchronous function and may take some time to execute deponds on your data size.
564
460
  *
565
- * @returns
566
- * | Property | Description |
567
- * | :-- | :-- |
568
- * | status | { error_code: number, reason: string } |
461
+ * @param {FlushReq} data - The request parameters.
462
+ * @param {string[]} data.collection_names - Array of collection names.
463
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
569
464
  *
570
- * #### Example
465
+ * @returns {Promise<FlushResult>} The result of the operation.
466
+ * @returns {string} status.error_code - The error code of the operation.
467
+ * @returns {string} status.reason - The reason for the error, if any.
571
468
  *
469
+ * @example
572
470
  * ```
573
- * new milvusClient(MILUVS_ADDRESS).flush({
574
- * collection_names: ['my_collection'],
471
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
472
+ * const flushStatus = await milvusClient.flush({
473
+ * collection_names: ['my_collection'],
575
474
  * });
576
475
  * ```
577
476
  */
@@ -582,31 +481,27 @@ class Data extends Collection_1.Collection {
582
481
  !data.collection_names.length) {
583
482
  throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
584
483
  }
585
- const res = yield (0, __1.promisify)(this.client, 'Flush', data, data.timeout || this.timeout);
484
+ const res = yield (0, __1.promisify)(this.channelPool, 'Flush', data, data.timeout || this.timeout);
586
485
  return res;
587
486
  });
588
487
  }
589
488
  /**
590
- * It's same function as flush. But flushSync is sync function.
591
- * So you can ensure it's flushed after function return the result.
489
+ * This function is similar to the `flush` function, but it is synchronous.
490
+ * This ensures that the flush operation is completed before the function returns.
592
491
  *
593
- * @param data
594
- * | Property | Type | Description |
595
- * | :--- | :-- | :-- |
596
- * | collection_names | String[] | Array of collection names |
597
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
598
-
492
+ * @param {FlushReq} data - The request parameters.
493
+ * @param {string[]} data.collection_names - Array of collection names.
494
+ * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
599
495
  *
600
- * @returns
601
- * | Property | Description |
602
- * | :-- | :-- |
603
- * | status | { error_code: number, reason: string } |
604
- *
605
- * #### Example
496
+ * @returns {Promise<GetFlushStateResponse>} The result of the operation.
497
+ * @returns {string} status.error_code - The error code of the operation.
498
+ * @returns {string} status.reason - The reason for the error, if any.
606
499
  *
500
+ * @example
607
501
  * ```
608
- * new milvusClient(MILUVS_ADDRESS).flushSync({
609
- * collection_names: ['my_collection'],
502
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
503
+ * const flushSyncStatus = await milvusClient.flushSync({
504
+ * collection_names: ['my_collection'],
610
505
  * });
611
506
  * ```
612
507
  */
@@ -618,7 +513,7 @@ class Data extends Collection_1.Collection {
618
513
  throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
619
514
  }
620
515
  // copy flushed collection names
621
- const res = yield (0, __1.promisify)(this.client, 'Flush', data, data.timeout || this.timeout);
516
+ const res = yield (0, __1.promisify)(this.channelPool, 'Flush', data, data.timeout || this.timeout);
622
517
  // After flush will return collection segment ids, need use GetPersistentSegmentInfo to check segment flush status.
623
518
  const segIDs = Object.keys(res.coll_segIDs)
624
519
  .map(v => res.coll_segIDs[v].data)
@@ -635,32 +530,30 @@ class Data extends Collection_1.Collection {
635
530
  });
636
531
  }
637
532
  /**
638
- * Query vector data in Milvus. Current release of Milvus only supports expression as fieldname in [id1,id2,id3]
639
- *
640
- * @param data
641
- * | Property | Type | Description |
642
- * | :--- | :-- | :-- |
643
- * | collection_name | String | Collection name |
644
- * | expr or filter | String | Scalar field filter expression |
645
- * | partitions_names(optional) | String[] | Array of partition names |
646
- * | output_fields | String[] | Vector or scalar field to be returned |
647
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
648
-
649
- * | params | {key: value}[] | An optional key pair json array
650
- *
651
- * @returns
652
- * | Property | Description |
653
- * | :-- | :-- |
654
- * | status | { error_code: number,reason:string } |
655
- * | data | Data of all fields that you defined in `output_fields`, {field_name: value}[] |
656
- *
657
- *
658
- * #### Example
659
- *
533
+ * Query vector data in Milvus. Current release of Milvus only supports expression as fieldname in [id1,id2,id3].
534
+ *
535
+ * @param {QueryReq} data - The request parameters.
536
+ * @param {string} data.collection_name - Collection name.
537
+ * @param {string[]} [data.ids] - IDs to get.
538
+ * @param {string} [data.expr] - Scalar field filter expression.
539
+ * @param {string} [data.filter] - Equals to data.expr.
540
+ * @param {string[]} [data.partitions_names] - Array of partition names (optional).
541
+ * @param {string[]} data.output_fields - Vector or scalar field to be returned.
542
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
543
+ * @param {{key: value}[]} [data.params] - An optional key pair json array of search parameters.
544
+ * @param {OutputTransformers} data.transformers - The transformers for bf16 or f16 data, it accept bytes or sparse dic vector, it can ouput f32 array or other format(optional)
545
+ *
546
+ * @returns {Promise<QueryResults>} The result of the operation.
547
+ * @returns {string} status.error_code - The error code of the operation.
548
+ * @returns {string} status.reason - The reason for the error, if any.
549
+ * @returns {{field_name: value}[]} data - Data of all fields that you defined in `output_fields`.
550
+ *
551
+ * @example
660
552
  * ```
661
- * new milvusClient(MILUVS_ADDRESS).query({
553
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
554
+ * const queryResults = await milvusClient.query({
662
555
  * collection_name: 'my_collection',
663
- * expr: "age in [1,2,3,4,5,6,7,8]",
556
+ * filter: "age in [1,2,3,4,5,6,7,8]",
664
557
  * output_fields: ["age"],
665
558
  * });
666
559
  * ```
@@ -677,13 +570,25 @@ class Data extends Collection_1.Collection {
677
570
  if (typeof data.offset === 'number') {
678
571
  offset = { offset: data.offset };
679
572
  }
680
- // filter > expr or empty
681
- data.expr = data.filter || data.expr || '';
573
+ // id in expression
574
+ let primaryKeyInIdsExpression = '';
575
+ // if we have ids
576
+ if (data.ids && data.ids.length > 0) {
577
+ const pkField = yield this.getPkFieldName(data);
578
+ const pkFieldType = yield this.getPkFieldType(data);
579
+ // generate expr by different type of pk
580
+ primaryKeyInIdsExpression =
581
+ __1.DataTypeMap[pkFieldType] === __1.DataType.VarChar
582
+ ? `${pkField} in ["${data.ids.join('","')}"]`
583
+ : `${pkField} in [${data.ids.join(',')}]`;
584
+ }
585
+ // filter > expr or empty > ids
586
+ data.expr = data.filter || data.expr || primaryKeyInIdsExpression;
682
587
  // Execute the query and get the results
683
- const promise = yield (0, __1.promisify)(this.client, 'Query', Object.assign(Object.assign({}, data), { query_params: (0, __1.parseToKeyValue)(Object.assign(Object.assign({}, limits), offset)) }), data.timeout || this.timeout);
588
+ const promise = yield (0, __1.promisify)(this.channelPool, 'Query', Object.assign(Object.assign({}, data), { query_params: (0, __1.parseToKeyValue)(Object.assign(Object.assign({}, limits), offset)) }), data.timeout || this.timeout);
684
589
  // always get output_fields from fields_data
685
590
  const output_fields = promise.fields_data.map(f => f.field_name);
686
- const fieldsDataMap = (0, __1.buildFieldDataMap)(promise.fields_data);
591
+ const fieldsDataMap = (0, __1.buildFieldDataMap)(promise.fields_data, data.transformers);
687
592
  // For each output field, check if it has a fixed schema or not
688
593
  const fieldDataContainer = output_fields.map(field_name => {
689
594
  // Check if the field_name exists in the fieldsDataMap
@@ -718,6 +623,7 @@ class Data extends Collection_1.Collection {
718
623
  return __awaiter(this, void 0, void 0, function* () {
719
624
  const queryResult = yield this.query({
720
625
  collection_name: data.collection_name,
626
+ expr: data.expr || '',
721
627
  output_fields: [__1.DEFAULT_COUNT_QUERY_STRING],
722
628
  });
723
629
  return {
@@ -727,51 +633,34 @@ class Data extends Collection_1.Collection {
727
633
  });
728
634
  }
729
635
  /**
730
- * get vector data by providing ids in Milvus
731
- *
732
- * @param data
733
- * | Property | Type | Description |
734
- * | :--- | :-- | :-- |
735
- * | collection_name | String | Collection name |
736
- * | ids | String[] | ids to get |
737
- * | partitions_names(optional) | String[] | Array of partition names |
738
- * | output_fields | String[] | Vector or scalar field to be returned |
739
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
740
-
741
- * | params | {key: value}[] | An optional key pair json array
742
- *
743
- * @returns
744
- * | Property | Description |
745
- * | :-- | :-- |
746
- * | status | { error_code: number,reason:string } |
747
- * | data | Data of all fields that you defined in `output_fields`, {field_name: value}[] |
748
- *
749
- *
750
- * #### Example
751
- *
636
+ * Retrieve vector data by providing IDs in Milvus.
637
+ *
638
+ * @param {GetReq} data - The request parameters.
639
+ * @param {string} data.collection_name - Collection name.
640
+ * @param {string[]} data.ids - IDs to get.
641
+ * @param {string[]} [data.partitions_names] - Array of partition names (optional).
642
+ * @param {string[]} data.output_fields - Vector or scalar field to be returned.
643
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
644
+ * @param {{key: value}[]} [data.params] - An optional key pair json array.
645
+ *
646
+ * @returns {Promise<QueryResults>} The result of the operation.
647
+ * @returns {string} status.error_code - The error code of the operation.
648
+ * @returns {string} status.reason - The reason for the error, if any.
649
+ * @returns {{field_name: value}[]} data - Data of all fields that you defined in `output_fields`.
650
+ *
651
+ * @example
752
652
  * ```
753
- * new milvusClient(MILUVS_ADDRESS).get({
653
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
654
+ * const getResults = await milvusClient.get({
754
655
  * collection_name: 'my_collection',
755
- * ids: [1,2,3,4,5,6,7,8],
656
+ * ids: ['1','2','3','4','5','6','7','8'],
756
657
  * output_fields: ["age"],
757
658
  * });
758
659
  * ```
759
660
  */
760
661
  get(data) {
761
662
  return __awaiter(this, void 0, void 0, function* () {
762
- (0, __1.checkCollectionName)(data);
763
- const pkField = yield this.getPkFieldName(data);
764
- if (!data.ids || data.ids.length === 0) {
765
- throw new Error(__1.ERROR_REASONS.IDS_REQUIRED);
766
- }
767
- const pkFieldType = yield this.getPkFieldType(data);
768
- // generate expr by different type of pk
769
- const expr = __1.DataTypeMap[pkFieldType] === __1.DataType.VarChar
770
- ? `${pkField} in ["${data.ids.join('","')}"]`
771
- : `${pkField} in [${data.ids.join(',')}]`;
772
- // build query req
773
- const req = Object.assign(Object.assign({}, data), { expr });
774
- return this.query(req);
663
+ return this.query(data);
775
664
  });
776
665
  }
777
666
  /**
@@ -786,34 +675,30 @@ class Data extends Collection_1.Collection {
786
675
  if (!data || !data.request || !data.request.metric_type) {
787
676
  throw new Error(__1.ERROR_REASONS.GET_METRIC_CHECK_PARAMS);
788
677
  }
789
- const res = yield (0, __1.promisify)(this.client, 'GetMetrics', {
678
+ const res = yield (0, __1.promisify)(this.channelPool, 'GetMetrics', {
790
679
  request: JSON.stringify(data.request),
791
680
  }, data.timeout || this.timeout);
792
681
  return Object.assign(Object.assign({}, res), { response: JSON.parse(res.response) });
793
682
  });
794
683
  }
795
684
  /**
796
- * Get flush state by segment ids
685
+ * Get the flush state of specified segment IDs in Milvus.
797
686
  *
798
- * @param data
799
- * | Property | Type | Description |
800
- * | :--- | :-- | :-- |
801
- * | segmentIDs | Array | The segment ids |
802
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
687
+ * @param {GetFlushStateReq} data - The request parameters.
688
+ * @param {number[]} data.segmentIDs - The segment IDs.
689
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
803
690
  *
804
- * @returns
805
- * | Property | Description |
806
- * | :--- | :-- |
807
- * | status | { error_code: number,reason:string } |
808
- * | flushed | segments flushed or not |
809
- *
810
- *
811
- * #### Example
691
+ * @returns {Promise<GetFlushStateResponse>} The result of the operation.
692
+ * @returns {string} status.error_code - The error code of the operation.
693
+ * @returns {string} status.reason - The reason for the error, if any.
694
+ * @returns {boolean[]} flushed - Array indicating whether each segment is flushed or not.
812
695
  *
696
+ * @example
813
697
  * ```
814
- * const res = await milvusClient.getFlushState({
815
- * segmentIDs: segIds,
816
- * });
698
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
699
+ * const flushState = await milvusClient.getFlushState({
700
+ * segmentIDs: [1,2,3,4],
701
+ * });
817
702
  * ```
818
703
  */
819
704
  getFlushState(data) {
@@ -821,35 +706,31 @@ class Data extends Collection_1.Collection {
821
706
  if (!data || !data.segmentIDs) {
822
707
  throw new Error(__1.ERROR_REASONS.GET_FLUSH_STATE_CHECK_PARAMS);
823
708
  }
824
- const res = yield (0, __1.promisify)(this.client, 'GetFlushState', data, data.timeout || this.timeout);
709
+ const res = yield (0, __1.promisify)(this.channelPool, 'GetFlushState', data, data.timeout || this.timeout);
825
710
  return res;
826
711
  });
827
712
  }
828
713
  /**
829
- * Do load balancing operation from source query node to destination query node.
830
- * Only work in cluster milvus.
714
+ * Perform a load balancing operation from a source query node to destination query nodes.
715
+ * This function only works in a Milvus cluster.
831
716
  *
832
- * @param data
833
- * | Property | Type | Description |
834
- * | :--- | :-- | :-- |
835
- * | src_nodeID | number | The source query node id to balance. |
836
- * | dst_nodeIDs | number[] | The destination query node ids to balance.(optional) |
837
- * | sealed_segmentIDs | number[] | Sealed segment ids to balance.(optional) |
838
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
839
- *
840
- * @returns
841
- * | Property | Description |
842
- * | :--- | :-- |
843
- * | status | { error_code: number,reason:string } |
844
- * | infos | segments information |
717
+ * @param {LoadBalanceReq} data - The request parameters.
718
+ * @param {number} data.src_nodeID - The source query node id to balance.
719
+ * @param {number[]} [data.dst_nodeIDs] - The destination query node ids to balance (optional).
720
+ * @param {number[]} [data.sealed_segmentIDs] - Sealed segment ids to balance (optional).
721
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
845
722
  *
723
+ * @returns {Promise<ResStatus>} The result of the operation.
724
+ * @returns {string} status.error_code - The error code of the operation.
725
+ * @returns {string} status.reason - The reason for the error, if any.
726
+ * @returns {SegmentInfo[]} infos - Information about the segments.
846
727
  *
847
- * #### Example
848
- *
728
+ * @example
849
729
  * ```
850
- * const res = await loadBalance({
851
- * src_nodeID: 31,
852
- * });
730
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
731
+ * const loadBalanceStatus = await milvusClient.loadBalance({
732
+ * src_nodeID: 31,
733
+ * });
853
734
  * ```
854
735
  */
855
736
  loadBalance(data) {
@@ -857,33 +738,28 @@ class Data extends Collection_1.Collection {
857
738
  if (!data || !data.src_nodeID) {
858
739
  throw new Error(__1.ERROR_REASONS.LOAD_BALANCE_CHECK_PARAMS);
859
740
  }
860
- const res = yield (0, __1.promisify)(this.client, 'LoadBalance', data, data.timeout || this.timeout);
741
+ const res = yield (0, __1.promisify)(this.channelPool, 'LoadBalance', data, data.timeout || this.timeout);
861
742
  return res;
862
743
  });
863
744
  }
864
745
  /**
865
746
  * Notifies Proxy to return segments information from query nodes.
866
747
  *
867
- * @param data
868
- * | Property | Type | Description |
869
- * | :--- | :-- | :-- |
870
- * | collectionName | String | The name of the collection to get segments info. |
871
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
872
- *
873
- *
874
- * @returns
875
- * | Property | Description |
876
- * | :--- | :-- |
877
- * | status | { error_code: number,reason:string } |
878
- * | infos | QuerySegmentInfo is the growing segments's information in query cluster. |
748
+ * @param {GetQuerySegmentInfoReq} data - The request parameters.
749
+ * @param {string} data.collectionName - The name of the collection to get segments info.
750
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
879
751
  *
752
+ * @returns {Promise<GetQuerySegmentInfoResponse>} The result of the operation.
753
+ * @returns {string} status.error_code - The error code of the operation.
754
+ * @returns {string} status.reason - The reason for the error, if any.
755
+ * @returns {QuerySegmentInfo[]} infos - The growing segments' information in query cluster.
880
756
  *
881
- * #### Example
882
- *
757
+ * @example
883
758
  * ```
884
- * const res = await getQuerySegmentInfo({
885
- * collectionName: COLLECTION,
886
- * });
759
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
760
+ * const querySegmentInfo = await milvusClient.getQuerySegmentInfo({
761
+ * collectionName: 'my_collection',
762
+ * });
887
763
  * ```
888
764
  */
889
765
  getQuerySegmentInfo(data) {
@@ -891,33 +767,28 @@ class Data extends Collection_1.Collection {
891
767
  if (!data || !data.collectionName) {
892
768
  throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
893
769
  }
894
- const res = yield (0, __1.promisify)(this.client, 'GetQuerySegmentInfo', data, data.timeout || this.timeout);
770
+ const res = yield (0, __1.promisify)(this.channelPool, 'GetQuerySegmentInfo', data, data.timeout || this.timeout);
895
771
  return res;
896
772
  });
897
773
  }
898
- /**data
774
+ /**
899
775
  * Notifies Proxy to return segments information from data nodes.
900
776
  *
901
- * @param data
902
- * | Property | Type | Description |
903
- * | :--- | :-- | :-- |
904
- * | collectionName | String | The name of the collection to get segments info. |
905
- * | timeout? | number | An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined |
777
+ * @param {GetPersistentSegmentInfoReq} data - The request parameters.
778
+ * @param {string} data.collectionName - The name of the collection to get segments info.
779
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
906
780
  *
781
+ * @returns {Promise<GetPersistentSegmentInfoResponse>} The result of the operation.
782
+ * @returns {string} status.error_code - The error code of the operation.
783
+ * @returns {string} status.reason - The reason for the error, if any.
784
+ * @returns {PersistentSegmentInfo[]} infos - The growing segments' information in data cluster.
907
785
  *
908
- * @returns
909
- * | Property | Description |
910
- * | :--- | :-- |
911
- * | status | { error_code: number,reason:string } |
912
- * | infos | getPersistentSegmentInfo is the growing segments's information in query cluster. |
913
- *
914
- *
915
- * #### Example
916
- *
786
+ * @example
917
787
  * ```
918
- * const res = await getPersistentSegmentInfo({
919
- * collectionName: COLLECTION,
920
- * });
788
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
789
+ * const persistentSegmentInfo = await milvusClient.getPersistentSegmentInfo({
790
+ * collectionName: 'my_collection',
791
+ * });
921
792
  * ```
922
793
  */
923
794
  getPersistentSegmentInfo(data) {
@@ -925,34 +796,30 @@ class Data extends Collection_1.Collection {
925
796
  if (!data || !data.collectionName) {
926
797
  throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
927
798
  }
928
- const res = yield (0, __1.promisify)(this.client, 'GetPersistentSegmentInfo', data, data.timeout || this.timeout);
799
+ const res = yield (0, __1.promisify)(this.channelPool, 'GetPersistentSegmentInfo', data, data.timeout || this.timeout);
929
800
  return res;
930
801
  });
931
802
  }
932
803
  /**
933
- * Import data from files
804
+ * Import data from files.
934
805
  *
935
- * @param data
936
- * | Property | Type | Description |
937
- * | :--- | :-- | :-- |
938
- * | collection_name | String | The name of the collection |
939
- * | files | string[] | File path array |
940
- *
941
- *
942
- * @returns
943
- * | Property | Description |
944
- * | :--- | :-- |
945
- * | status | { error_code: number,reason:string } |
946
- * | tasks | taskId array |
806
+ * @param {ImportReq} data - The request parameters.
807
+ * @param {string} data.collection_name - The name of the collection.
808
+ * @param {string[]} data.files - Array of file paths.
809
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
947
810
  *
811
+ * @returns {Promise<ImportResponse>} The result of the operation.
812
+ * @returns {string} status.error_code - The error code of the operation.
813
+ * @returns {string} status.reason - The reason for the error, if any.
814
+ * @returns {string[]} tasks - Array of task IDs.
948
815
  *
949
- * #### Example
950
- *
816
+ * @example
951
817
  * ```
952
- * const res = await bulkInsert({
953
- * collection_name: COLLECTION,
954
- * files: [`path-to-data-file.json`]
955
- * });
818
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
819
+ * const importResponse = await milvusClient.bulkInsert({
820
+ * collection_name: 'my_collection',
821
+ * files: ['path-to-data-file.json'],
822
+ * });
956
823
  * ```
957
824
  */
958
825
  /* istanbul ignore next */
@@ -964,37 +831,33 @@ class Data extends Collection_1.Collection {
964
831
  if (!data || !data.files) {
965
832
  throw new Error(__1.ERROR_REASONS.IMPORT_FILE_CHECK);
966
833
  }
967
- const res = yield (0, __1.promisify)(this.client, 'Import', Object.assign(Object.assign({}, data), { options: data.options || [] }), data.timeout || this.timeout);
834
+ const res = yield (0, __1.promisify)(this.channelPool, 'Import', Object.assign(Object.assign({}, data), { options: data.options || [] }), data.timeout || this.timeout);
968
835
  return res;
969
836
  });
970
837
  }
971
838
  /**
972
- * List import tasks
973
- *
974
- * @param data
975
- * | Property | Type | Description |
976
- * | :--- | :-- | :-- |
977
- * | collection_name | String | The name of the collection |
978
- * | limit | number | optional, maximum number of tasks returned, list all tasks if the value is 0 |
979
- *
980
- *
981
- * @returns
982
- * | Property | Description |
983
- * | :--- | :-- |
984
- * | status | { error_code: number,reason:string } |
985
- * | state | import state |
986
- * | row_count | how many rows to import|
987
- * | id_list| id lists |
988
- * | collection_id | collection to be imported to |
989
- * | tasks | taskId array |
990
- *
991
- *
992
- * #### Example
993
- *
839
+ * List import tasks.
840
+ *
841
+ * @param {ListImportTasksReq} data - The request parameters.
842
+ * @param {string} data.collection_name - The name of the collection.
843
+ * @param {number} [data.limit] - Optional, maximum number of tasks returned, list all tasks if the value is 0.
844
+ * @param {number} [data.timeout] - An optional duration of time in millisecond to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined.
845
+ *
846
+ * @returns {Promise<ListImportTasksResponse>} The result of the operation.
847
+ * @returns {string} status.error_code - The error code of the operation.
848
+ * @returns {string} status.reason - The reason for the error, if any.
849
+ * @returns {string} state - Import state.
850
+ * @returns {number} row_count - How many rows to import.
851
+ * @returns {string[]} id_list - ID lists.
852
+ * @returns {string} collection_id - Collection to be imported to.
853
+ * @returns {string[]} tasks - TaskId array.
854
+ *
855
+ * @example
994
856
  * ```
995
- * const res = await listImportTasks({
996
- * collection_name: COLLECTION
997
- * });
857
+ * const milvusClient = new milvusClient(MILUVS_ADDRESS);
858
+ * const listImportTasksResponse = await milvusClient.listImportTasks({
859
+ * collection_name: 'my_collection',
860
+ * });
998
861
  * ```
999
862
  */
1000
863
  /* istanbul ignore next */
@@ -1003,7 +866,7 @@ class Data extends Collection_1.Collection {
1003
866
  if (!data || !data.collection_name) {
1004
867
  throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
1005
868
  }
1006
- const res = yield (0, __1.promisify)(this.client, 'ListImportTasks', Object.assign(Object.assign({}, data), { limit: data.limit || 0 }), data.timeout || this.timeout);
869
+ const res = yield (0, __1.promisify)(this.channelPool, 'ListImportTasks', Object.assign(Object.assign({}, data), { limit: data.limit || 0 }), data.timeout || this.timeout);
1007
870
  return res;
1008
871
  });
1009
872
  }