@zilliz/milvus2-sdk-node 1.0.17 → 1.1.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 (52) hide show
  1. package/README.md +1 -1
  2. package/dist/grpc-proto/common.proto +35 -0
  3. package/dist/grpc-proto/milvus.proto +315 -52
  4. package/dist/milvus/Client.d.ts +2 -0
  5. package/dist/milvus/Client.js +11 -0
  6. package/dist/milvus/Client.js.map +1 -1
  7. package/dist/milvus/Collection.d.ts +114 -4
  8. package/dist/milvus/Collection.js +267 -19
  9. package/dist/milvus/Collection.js.map +1 -1
  10. package/dist/milvus/Data.d.ts +141 -6
  11. package/dist/milvus/Data.js +304 -21
  12. package/dist/milvus/Data.js.map +1 -1
  13. package/dist/milvus/MilvusIndex.js +15 -3
  14. package/dist/milvus/MilvusIndex.js.map +1 -1
  15. package/dist/milvus/Partition.js +28 -7
  16. package/dist/milvus/Partition.js.map +1 -1
  17. package/dist/milvus/Utils.d.ts +1 -0
  18. package/dist/milvus/Utils.js +8 -0
  19. package/dist/milvus/Utils.js.map +1 -0
  20. package/dist/milvus/const/ErrorReason.d.ts +18 -3
  21. package/dist/milvus/const/ErrorReason.js +17 -2
  22. package/dist/milvus/const/ErrorReason.js.map +1 -1
  23. package/dist/milvus/index.d.ts +12 -1
  24. package/dist/milvus/index.js +77 -4
  25. package/dist/milvus/index.js.map +1 -1
  26. package/dist/milvus/types/Collection.d.ts +27 -10
  27. package/dist/milvus/types/Common.d.ts +13 -0
  28. package/dist/milvus/types/Common.js +16 -1
  29. package/dist/milvus/types/Common.js.map +1 -1
  30. package/dist/milvus/types/Data.d.ts +42 -0
  31. package/dist/milvus/types/{Insert.js → Data.js} +1 -1
  32. package/dist/milvus/types/Data.js.map +1 -0
  33. package/dist/milvus/types/Response.d.ts +47 -7
  34. package/dist/milvus/types/Response.js +1 -1
  35. package/dist/milvus/types/Response.js.map +1 -1
  36. package/dist/milvus/types/Search.d.ts +4 -3
  37. package/dist/milvus/types.d.ts +3 -3
  38. package/dist/milvus/utils/Format.d.ts +76 -0
  39. package/dist/milvus/utils/Format.js +126 -3
  40. package/dist/milvus/utils/Format.js.map +1 -1
  41. package/dist/milvus/utils/Validate.js +9 -1
  42. package/dist/milvus/utils/Validate.js.map +1 -1
  43. package/dist/milvus/utils/index.d.ts +1 -0
  44. package/dist/milvus/utils/index.js +5 -1
  45. package/dist/milvus/utils/index.js.map +1 -1
  46. package/dist/sdk.json +1 -1
  47. package/dist/utils/index.d.ts +1 -0
  48. package/dist/utils/index.js +4 -2
  49. package/dist/utils/index.js.map +1 -1
  50. package/package.json +7 -4
  51. package/dist/milvus/types/Insert.d.ts +0 -18
  52. package/dist/milvus/types/Insert.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { Client } from "./Client";
2
2
  import { Collection } from "./Collection";
3
- import { FlushReq, InsertReq } from "./types/Insert";
4
- import { FlushResult, GetMetricsResponse, MutationResult, QueryResults, SearchResults } from "./types/Response";
3
+ import { CalcDistanceReq, DeleteEntitiesReq, FlushReq, GetFlushStateReq, GetQuerySegmentInfoReq, InsertReq, LoadBalanceReq } from "./types/Data";
4
+ import { CalcDistanceResponse, FlushResult, GetFlushStateResponse, GetMetricsResponse, GetQuerySegmentInfoResponse, MutationResult, QueryResults, ResStatus, SearchResults } from "./types/Response";
5
5
  import { GetMetricsRequest, QueryReq, SearchReq } from "./types/Search";
6
6
  export declare class Data extends Client {
7
7
  vectorTypes: number[];
@@ -40,6 +40,33 @@ export declare class Data extends Client {
40
40
  * ```
41
41
  */
42
42
  insert(data: InsertReq): Promise<MutationResult>;
43
+ /**
44
+ * Delete entities in Milvus
45
+ *
46
+ * @param data
47
+ * | Property | Type | Description |
48
+ * | :---------------------- | :-------------------- | :------------------------------- |
49
+ * | collection_name | String | Collection name |
50
+ * | partition_name(optional)| String | Partition name |
51
+ * | expr | String | Boolean expression used to filter attribute. |
52
+ *
53
+ * @return
54
+ * | Property | Description |
55
+ * | :-------------| :------------------------------- |
56
+ * | status | { error_code: number, reason: string }|
57
+ * | IDs | ID array of the successfully deleted data |
58
+ *
59
+ *
60
+ * #### Example
61
+ *
62
+ * ```
63
+ * new milvusClient(MILUVS_ADDRESS).dataManager.deleteEntities({
64
+ * collection_name: COLLECTION_NAME,
65
+ * expr: 'id in [1,2,3,4]'
66
+ * });
67
+ * ```
68
+ */
69
+ deleteEntities(data: DeleteEntitiesReq): Promise<MutationResult>;
43
70
  /**
44
71
  * Perform vector similarity search.
45
72
  *
@@ -53,14 +80,14 @@ export declare class Data extends Client {
53
80
  * | vectors | Number[][] | Original vector to search with |
54
81
  * | output_fields(optional) | String[] | Support scalar field |
55
82
  * | vector_type | enum | Binary field -> 100, Float field -> 101 |
83
+ * | travel_timestamp | number | We can get timestamp after insert success. Use this timestamp we can time travel in vector search.|
56
84
 
57
85
  * @return
58
86
  * | Property | Description |
59
87
  * | :-------------| :------------------------------- |
60
88
  * | status | { error_code: number, reason: string }|
61
- * | succ_index | Insert successful index array |
62
- * | err_index | Insert failed index array |
63
- * | IDs | Insert successful id array |
89
+ * | results | {score:number,id:string}[]; |
90
+ *
64
91
  *
65
92
  *
66
93
  * #### Example
@@ -84,7 +111,7 @@ export declare class Data extends Client {
84
111
  search(data: SearchReq): Promise<SearchResults>;
85
112
  /**
86
113
  * Milvus temporarily buffers the newly inserted vectors in the cache. Call `flush()` to persist them to the object storage.
87
- *
114
+ * It's async function, so it's will take some times to excute.
88
115
  * @param data
89
116
  * | Property | Type | Description |
90
117
  * | :---------------------- | :---- | :------------------------------- |
@@ -104,6 +131,29 @@ export declare class Data extends Client {
104
131
  * ```
105
132
  */
106
133
  flush(data: FlushReq): Promise<FlushResult>;
134
+ /**
135
+ * It's same function as flush. But flushSync is sync function.
136
+ * So you can ensure it's flushed after function return the result.
137
+ *
138
+ * @param data
139
+ * | Property | Type | Description |
140
+ * | :---------------------- | :---- | :------------------------------- |
141
+ * | collection_names | String[] | Array of collection names |
142
+ *
143
+ * @return
144
+ * | Property | Description |
145
+ * | :-------------| :------------------------------- |
146
+ * | status | { error_code: number, reason: string }|
147
+ *
148
+ * #### Example
149
+ *
150
+ * ```
151
+ * new milvusClient(MILUVS_ADDRESS).dataManager.flushSync({
152
+ * collection_names: ['my_collection'],
153
+ * });
154
+ * ```
155
+ */
156
+ flushSync(data: FlushReq): Promise<GetFlushStateResponse>;
107
157
  /**
108
158
  * Query vector data in Milvus. Current release of Milvus only supports expression as fieldname in [id1,id2,id3]
109
159
  *
@@ -143,4 +193,89 @@ export declare class Data extends Client {
143
193
  * | request | object | Only allow "system_info" for now |
144
194
  */
145
195
  getMetric(data: GetMetricsRequest): Promise<GetMetricsResponse>;
196
+ /**
197
+ * @ignore
198
+ * @param data
199
+ */
200
+ calcDistance(data: CalcDistanceReq): Promise<CalcDistanceResponse>;
201
+ /**
202
+ * Get flush state by segment ids
203
+ *
204
+ * @param data
205
+ * | Property | Type | Description |
206
+ * | :---------------------- | :---- | :------------------------------- |
207
+ * | segmentIDs | Array | The segment ids |
208
+ *
209
+ *
210
+ *
211
+ * @return
212
+ * | Property | Description |
213
+ * | :-----------| :------------------------------- |
214
+ * | status | { error_code: number,reason:string } |
215
+ * | flushed | segments flushed or not |
216
+ *
217
+ *
218
+ * #### Example
219
+ *
220
+ * ```
221
+ * const res = await milvusClient.dataManager.getFlushState({
222
+ * segmentIDs: segIds,
223
+ * });
224
+ * ```
225
+ */
226
+ getFlushState(data: GetFlushStateReq): Promise<GetFlushStateResponse>;
227
+ /**
228
+ * Do load balancing operation from source query node to destination query node.
229
+ * Only work in cluster milvus.
230
+ *
231
+ * @param data
232
+ * | Property | Type | Description |
233
+ * | :-------------------| :---- | :------------------------------- |
234
+ * | src_nodeID | number | The source query node id to balance. |
235
+ * | dst_nodeIDs | number[] | The destination query node ids to balance.(optional) |
236
+ * | sealed_segmentIDs | number[] | Sealed segment ids to balance.(optional) |
237
+ *
238
+ *
239
+ * @return
240
+ * | Property | Description |
241
+ * | :-----------| :------------------------------- |
242
+ * | status | { error_code: number,reason:string } |
243
+ * | infos | segments infomations |
244
+ *
245
+ *
246
+ * #### Example
247
+ *
248
+ * ```
249
+ * const res = await dataManager.loadBalance({
250
+ * src_nodeID: 31,
251
+ * });
252
+ * ```
253
+ */
254
+ loadBalance(data: LoadBalanceReq): Promise<ResStatus>;
255
+ /**
256
+ * Notifies Proxy to return segments information from query nodes.
257
+ *
258
+ * @param data
259
+ * | Property | Type | Description |
260
+ * | :---------------------- | :---- | :------------------------------- |
261
+ * | collectionName | String | The name of the collection to get segments info. |
262
+ *
263
+ *
264
+ *
265
+ * @return
266
+ * | Property | Description |
267
+ * | :-----------| :------------------------------- |
268
+ * | status | { error_code: number,reason:string } |
269
+ * | infos | QuerySegmentInfo is the growing segments's information in query cluster. |
270
+ *
271
+ *
272
+ * #### Example
273
+ *
274
+ * ```
275
+ * const res = await dataManager.getQuerySegmentInfo({
276
+ * collectionName: COLLECTION,
277
+ * });
278
+ * ```
279
+ */
280
+ getQuerySegmentInfo(data: GetQuerySegmentInfoReq): Promise<GetQuerySegmentInfoResponse>;
146
281
  }
@@ -61,6 +61,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
62
  }
63
63
  };
64
+ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
65
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
66
+ to[j] = from[i];
67
+ return to;
68
+ };
64
69
  var __importDefault = (this && this.__importDefault) || function (mod) {
65
70
  return (mod && mod.__esModule) ? mod : { "default": mod };
66
71
  };
@@ -72,7 +77,7 @@ var Client_1 = require("./Client");
72
77
  var ErrorReason_1 = require("./const/ErrorReason");
73
78
  var Common_1 = require("./types/Common");
74
79
  var Response_1 = require("./types/Response");
75
- var utils_2 = require("./utils");
80
+ var index_1 = require("./utils/index");
76
81
  var Blob_1 = require("./utils/Blob");
77
82
  var path_1 = __importDefault(require("path"));
78
83
  var Format_1 = require("./utils/Format");
@@ -124,6 +129,12 @@ var Data = /** @class */ (function (_super) {
124
129
  return __generator(this, function (_a) {
125
130
  switch (_a.label) {
126
131
  case 0:
132
+ this.checkCollectionName(data);
133
+ if (!data.fields_data ||
134
+ !Array.isArray(data.fields_data) ||
135
+ !data.fields_data.length) {
136
+ throw new Error(ErrorReason_1.ERROR_REASONS.INSERT_CHECK_FILEDS_DATA_IS_REQUIRED);
137
+ }
127
138
  collection_name = data.collection_name;
128
139
  return [4 /*yield*/, this.collectionManager.describeCollection({
129
140
  collection_name: collection_name,
@@ -138,7 +149,7 @@ var Data = /** @class */ (function (_super) {
138
149
  .map(function (v) { return ({
139
150
  name: v.name,
140
151
  type: v.data_type,
141
- dim: Number(utils_2.findKeyValue(v.type_params, "dim")),
152
+ dim: Number(index_1.findKeyValue(v.type_params, "dim")),
142
153
  value: [],
143
154
  }); });
144
155
  params = __assign(__assign({}, data), { num_rows: data.fields_data.length });
@@ -175,8 +186,6 @@ var Data = /** @class */ (function (_super) {
175
186
  // milvus return string for field type, so we define the DataTypeMap to the value we need.
176
187
  // but if milvus change the string, may casue we cant find value.
177
188
  var type = Common_1.DataTypeMap[v.type.toLowerCase()];
178
- if (!type) {
179
- }
180
189
  var key = _this.vectorTypes.includes(type) ? "vectors" : "scalars";
181
190
  var dataKey = "float_vector";
182
191
  switch (type) {
@@ -200,8 +209,11 @@ var Data = /** @class */ (function (_super) {
200
209
  case Common_1.DataType.Int8:
201
210
  dataKey = "int_data";
202
211
  break;
203
- default:
212
+ case Common_1.DataType.Bool:
213
+ dataKey = "bool_data";
204
214
  break;
215
+ default:
216
+ throw new Error(ErrorReason_1.ERROR_REASONS.INSERT_CHECK_WRONG_DATA_TYPE);
205
217
  }
206
218
  return _a = {
207
219
  type: type,
@@ -234,6 +246,49 @@ var Data = /** @class */ (function (_super) {
234
246
  });
235
247
  });
236
248
  };
249
+ /**
250
+ * Delete entities in Milvus
251
+ *
252
+ * @param data
253
+ * | Property | Type | Description |
254
+ * | :---------------------- | :-------------------- | :------------------------------- |
255
+ * | collection_name | String | Collection name |
256
+ * | partition_name(optional)| String | Partition name |
257
+ * | expr | String | Boolean expression used to filter attribute. |
258
+ *
259
+ * @return
260
+ * | Property | Description |
261
+ * | :-------------| :------------------------------- |
262
+ * | status | { error_code: number, reason: string }|
263
+ * | IDs | ID array of the successfully deleted data |
264
+ *
265
+ *
266
+ * #### Example
267
+ *
268
+ * ```
269
+ * new milvusClient(MILUVS_ADDRESS).dataManager.deleteEntities({
270
+ * collection_name: COLLECTION_NAME,
271
+ * expr: 'id in [1,2,3,4]'
272
+ * });
273
+ * ```
274
+ */
275
+ Data.prototype.deleteEntities = function (data) {
276
+ return __awaiter(this, void 0, void 0, function () {
277
+ var promise;
278
+ return __generator(this, function (_a) {
279
+ switch (_a.label) {
280
+ case 0:
281
+ if (!data || !data.collection_name || !data.expr) {
282
+ throw new Error(ErrorReason_1.ERROR_REASONS.DELETE_PARAMS_CHECK);
283
+ }
284
+ return [4 /*yield*/, utils_1.promisify(this.client, "Delete", data)];
285
+ case 1:
286
+ promise = _a.sent();
287
+ return [2 /*return*/, promise];
288
+ }
289
+ });
290
+ });
291
+ };
237
292
  /**
238
293
  * Perform vector similarity search.
239
294
  *
@@ -247,14 +302,14 @@ var Data = /** @class */ (function (_super) {
247
302
  * | vectors | Number[][] | Original vector to search with |
248
303
  * | output_fields(optional) | String[] | Support scalar field |
249
304
  * | vector_type | enum | Binary field -> 100, Float field -> 101 |
305
+ * | travel_timestamp | number | We can get timestamp after insert success. Use this timestamp we can time travel in vector search.|
250
306
 
251
307
  * @return
252
308
  * | Property | Description |
253
309
  * | :-------------| :------------------------------- |
254
310
  * | status | { error_code: number, reason: string }|
255
- * | succ_index | Insert successful index array |
256
- * | err_index | Insert failed index array |
257
- * | IDs | Insert successful id array |
311
+ * | results | {score:number,id:string}[]; |
312
+ *
258
313
  *
259
314
  *
260
315
  * #### Example
@@ -278,14 +333,20 @@ var Data = /** @class */ (function (_super) {
278
333
  Data.prototype.search = function (data) {
279
334
  var _a;
280
335
  return __awaiter(this, void 0, void 0, function () {
281
- var root, collectionInfo, targetField, dim, vectorType, dimension, PlaceholderGroup, placeholderGroupParams, placeholderGroupBytes, promise, results, _b, topks, scores_1, fields_data, ids, fieldsData_1, idData_1;
336
+ var root, collectionInfo, targetField, dim, vectorType, dimension, PlaceholderGroup, placeholderGroupParams, placeholderGroupBytes, promise, results, round_decimal, _b, topks, scores_1, fields_data, ids, fieldsData_1, idData_1;
282
337
  return __generator(this, function (_c) {
283
338
  switch (_c.label) {
284
339
  case 0: return [4 /*yield*/, protobufjs_1.default.load(protoPath)];
285
340
  case 1:
286
341
  root = _c.sent();
287
- if (!root)
288
- throw new Error("Missing milvus proto file");
342
+ this.checkCollectionName(data);
343
+ if (!data.search_params ||
344
+ !data.search_params.anns_field ||
345
+ !data.search_params.metric_type ||
346
+ !data.search_params.topk ||
347
+ !data.search_params.params) {
348
+ throw new Error(ErrorReason_1.ERROR_REASONS.SEARCH_PARAMS_IS_REQUIRED);
349
+ }
289
350
  if (!this.vectorTypes.includes(data.vector_type))
290
351
  throw new Error(ErrorReason_1.ERROR_REASONS.SEARCH_MISS_VECTOR_TYPE);
291
352
  return [4 /*yield*/, this.collectionManager.describeCollection({
@@ -297,7 +358,7 @@ var Data = /** @class */ (function (_super) {
297
358
  if (!targetField) {
298
359
  throw new Error(ErrorReason_1.ERROR_REASONS.SEARCH_NOT_FIND_VECTOR_FIELD);
299
360
  }
300
- dim = utils_2.findKeyValue(targetField.type_params, "dim");
361
+ dim = index_1.findKeyValue(targetField.type_params, "dim");
301
362
  vectorType = Common_1.DataTypeMap[targetField.data_type.toLowerCase()];
302
363
  dimension = vectorType === Common_1.DataType.BinaryVector ? Number(dim) / 8 : Number(dim);
303
364
  if (!data.vectors[0] || data.vectors[0].length !== dimension) {
@@ -322,6 +383,7 @@ var Data = /** @class */ (function (_super) {
322
383
  case 3:
323
384
  promise = _c.sent();
324
385
  results = [];
386
+ round_decimal = data.search_params.round_decimal;
325
387
  if (promise.results) {
326
388
  _b = promise.results, topks = _b.topks, scores_1 = _b.scores, fields_data = _b.fields_data, ids = _b.ids;
327
389
  fieldsData_1 = fields_data.map(function (item, i) {
@@ -333,7 +395,7 @@ var Data = /** @class */ (function (_super) {
333
395
  data: value ? value[value === null || value === void 0 ? void 0 : value.data].data : "",
334
396
  };
335
397
  });
336
- idData_1 = (_a = ids[ids.id_field]) === null || _a === void 0 ? void 0 : _a.data;
398
+ idData_1 = ids ? (_a = ids[ids.id_field]) === null || _a === void 0 ? void 0 : _a.data : undefined;
337
399
  /**
338
400
  * milvus support mutilple querys to search
339
401
  * milvus will return all columns data
@@ -344,8 +406,11 @@ var Data = /** @class */ (function (_super) {
344
406
  var topk = Number(v);
345
407
  scores_1.splice(0, topk).forEach(function (score, scoreIndex) {
346
408
  var i = index === 0 ? scoreIndex : scoreIndex + topk;
409
+ var fixedScore = typeof round_decimal === "undefined" || round_decimal === -1
410
+ ? score
411
+ : Format_1.formatNumberPrecision(score, round_decimal);
347
412
  var result = {
348
- score: score,
413
+ score: fixedScore,
349
414
  id: idData_1 ? idData_1[i] : "",
350
415
  };
351
416
  fieldsData_1.forEach(function (field) {
@@ -365,7 +430,7 @@ var Data = /** @class */ (function (_super) {
365
430
  };
366
431
  /**
367
432
  * Milvus temporarily buffers the newly inserted vectors in the cache. Call `flush()` to persist them to the object storage.
368
- *
433
+ * It's async function, so it's will take some times to excute.
369
434
  * @param data
370
435
  * | Property | Type | Description |
371
436
  * | :---------------------- | :---- | :------------------------------- |
@@ -389,7 +454,13 @@ var Data = /** @class */ (function (_super) {
389
454
  var res;
390
455
  return __generator(this, function (_a) {
391
456
  switch (_a.label) {
392
- case 0: return [4 /*yield*/, utils_1.promisify(this.client, "Flush", data)];
457
+ case 0:
458
+ if (!data ||
459
+ !Array.isArray(data.collection_names) ||
460
+ !data.collection_names.length) {
461
+ throw new Error(ErrorReason_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
462
+ }
463
+ return [4 /*yield*/, utils_1.promisify(this.client, "Flush", data)];
393
464
  case 1:
394
465
  res = _a.sent();
395
466
  return [2 /*return*/, res];
@@ -397,6 +468,65 @@ var Data = /** @class */ (function (_super) {
397
468
  });
398
469
  });
399
470
  };
471
+ /**
472
+ * It's same function as flush. But flushSync is sync function.
473
+ * So you can ensure it's flushed after function return the result.
474
+ *
475
+ * @param data
476
+ * | Property | Type | Description |
477
+ * | :---------------------- | :---- | :------------------------------- |
478
+ * | collection_names | String[] | Array of collection names |
479
+ *
480
+ * @return
481
+ * | Property | Description |
482
+ * | :-------------| :------------------------------- |
483
+ * | status | { error_code: number, reason: string }|
484
+ *
485
+ * #### Example
486
+ *
487
+ * ```
488
+ * new milvusClient(MILUVS_ADDRESS).dataManager.flushSync({
489
+ * collection_names: ['my_collection'],
490
+ * });
491
+ * ```
492
+ */
493
+ Data.prototype.flushSync = function (data) {
494
+ return __awaiter(this, void 0, void 0, function () {
495
+ var res, segIDs, isFlushed, flushRes;
496
+ return __generator(this, function (_a) {
497
+ switch (_a.label) {
498
+ case 0:
499
+ if (!data ||
500
+ !Array.isArray(data.collection_names) ||
501
+ !data.collection_names.length) {
502
+ throw new Error(ErrorReason_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
503
+ }
504
+ return [4 /*yield*/, utils_1.promisify(this.client, "Flush", data)];
505
+ case 1:
506
+ res = _a.sent();
507
+ segIDs = Object.keys(res.coll_segIDs)
508
+ .map(function (v) { return res.coll_segIDs[v].data; })
509
+ .reduce(function (pre, cur) { return __spreadArray(__spreadArray([], pre), cur); }, []);
510
+ isFlushed = false;
511
+ flushRes = null;
512
+ _a.label = 2;
513
+ case 2:
514
+ if (!!isFlushed) return [3 /*break*/, 5];
515
+ return [4 /*yield*/, this.getFlushState({ segmentIDs: segIDs })];
516
+ case 3:
517
+ flushRes = _a.sent();
518
+ return [4 /*yield*/, index_1.sleep(100)];
519
+ case 4:
520
+ _a.sent();
521
+ isFlushed = flushRes.flushed;
522
+ return [3 /*break*/, 2];
523
+ case 5:
524
+ // Before Milvus pre-GA will throw error
525
+ return [2 /*return*/, flushRes];
526
+ }
527
+ });
528
+ });
529
+ };
400
530
  /**
401
531
  * Query vector data in Milvus. Current release of Milvus only supports expression as fieldname in [id1,id2,id3]
402
532
  *
@@ -432,7 +562,9 @@ var Data = /** @class */ (function (_super) {
432
562
  var promise, results, fieldsData;
433
563
  return __generator(this, function (_a) {
434
564
  switch (_a.label) {
435
- case 0: return [4 /*yield*/, utils_1.promisify(this.client, "Query", data)];
565
+ case 0:
566
+ this.checkCollectionName(data);
567
+ return [4 /*yield*/, utils_1.promisify(this.client, "Query", data)];
436
568
  case 1:
437
569
  promise = _a.sent();
438
570
  results = [];
@@ -440,7 +572,9 @@ var Data = /** @class */ (function (_super) {
440
572
  var _a;
441
573
  if (item.field === "vectors") {
442
574
  var key_1 = item.vectors.data;
443
- var vectorValue = item.vectors[key_1].data;
575
+ var vectorValue = key_1 === "float_vector"
576
+ ? item.vectors[key_1].data
577
+ : item.vectors[key_1].toJSON().data;
444
578
  // if binary vector , need use dim / 8 to split vector data
445
579
  var dim_1 = ((_a = item.vectors) === null || _a === void 0 ? void 0 : _a.data) === "float_vector"
446
580
  ? Number(item.vectors.dim)
@@ -500,9 +634,13 @@ var Data = /** @class */ (function (_super) {
500
634
  var res;
501
635
  return __generator(this, function (_a) {
502
636
  switch (_a.label) {
503
- case 0: return [4 /*yield*/, utils_1.promisify(this.client, "GetMetrics", {
504
- request: JSON.stringify(data.request),
505
- })];
637
+ case 0:
638
+ if (!data || !data.request || !data.request.metric_type) {
639
+ throw new Error(ErrorReason_1.ERROR_REASONS.GET_METRIC_CHECK_PARAMS);
640
+ }
641
+ return [4 /*yield*/, utils_1.promisify(this.client, "GetMetrics", {
642
+ request: JSON.stringify(data.request),
643
+ })];
506
644
  case 1:
507
645
  res = _a.sent();
508
646
  return [2 /*return*/, __assign(__assign({}, res), { response: JSON.parse(res.response) })];
@@ -510,6 +648,151 @@ var Data = /** @class */ (function (_super) {
510
648
  });
511
649
  });
512
650
  };
651
+ /**
652
+ * @ignore
653
+ * @param data
654
+ */
655
+ Data.prototype.calcDistance = function (data) {
656
+ return __awaiter(this, void 0, void 0, function () {
657
+ var res;
658
+ return __generator(this, function (_a) {
659
+ switch (_a.label) {
660
+ case 0: return [4 /*yield*/, utils_1.promisify(this.client, "CalcDistance", data)];
661
+ case 1:
662
+ res = _a.sent();
663
+ return [2 /*return*/, res];
664
+ }
665
+ });
666
+ });
667
+ };
668
+ /**
669
+ * Get flush state by segment ids
670
+ *
671
+ * @param data
672
+ * | Property | Type | Description |
673
+ * | :---------------------- | :---- | :------------------------------- |
674
+ * | segmentIDs | Array | The segment ids |
675
+ *
676
+ *
677
+ *
678
+ * @return
679
+ * | Property | Description |
680
+ * | :-----------| :------------------------------- |
681
+ * | status | { error_code: number,reason:string } |
682
+ * | flushed | segments flushed or not |
683
+ *
684
+ *
685
+ * #### Example
686
+ *
687
+ * ```
688
+ * const res = await milvusClient.dataManager.getFlushState({
689
+ * segmentIDs: segIds,
690
+ * });
691
+ * ```
692
+ */
693
+ Data.prototype.getFlushState = function (data) {
694
+ return __awaiter(this, void 0, void 0, function () {
695
+ var res;
696
+ return __generator(this, function (_a) {
697
+ switch (_a.label) {
698
+ case 0:
699
+ if (!data || !data.segmentIDs) {
700
+ throw new Error(ErrorReason_1.ERROR_REASONS.GET_FLUSH_STATE_CHECK_PARAMS);
701
+ }
702
+ return [4 /*yield*/, utils_1.promisify(this.client, "GetFlushState", data)];
703
+ case 1:
704
+ res = _a.sent();
705
+ return [2 /*return*/, res];
706
+ }
707
+ });
708
+ });
709
+ };
710
+ /**
711
+ * Do load balancing operation from source query node to destination query node.
712
+ * Only work in cluster milvus.
713
+ *
714
+ * @param data
715
+ * | Property | Type | Description |
716
+ * | :-------------------| :---- | :------------------------------- |
717
+ * | src_nodeID | number | The source query node id to balance. |
718
+ * | dst_nodeIDs | number[] | The destination query node ids to balance.(optional) |
719
+ * | sealed_segmentIDs | number[] | Sealed segment ids to balance.(optional) |
720
+ *
721
+ *
722
+ * @return
723
+ * | Property | Description |
724
+ * | :-----------| :------------------------------- |
725
+ * | status | { error_code: number,reason:string } |
726
+ * | infos | segments infomations |
727
+ *
728
+ *
729
+ * #### Example
730
+ *
731
+ * ```
732
+ * const res = await dataManager.loadBalance({
733
+ * src_nodeID: 31,
734
+ * });
735
+ * ```
736
+ */
737
+ Data.prototype.loadBalance = function (data) {
738
+ return __awaiter(this, void 0, void 0, function () {
739
+ var res;
740
+ return __generator(this, function (_a) {
741
+ switch (_a.label) {
742
+ case 0:
743
+ if (!data || !data.src_nodeID) {
744
+ throw new Error(ErrorReason_1.ERROR_REASONS.LOAD_BALANCE_CHECK_PARAMS);
745
+ }
746
+ return [4 /*yield*/, utils_1.promisify(this.client, "LoadBalance", data)];
747
+ case 1:
748
+ res = _a.sent();
749
+ return [2 /*return*/, res];
750
+ }
751
+ });
752
+ });
753
+ };
754
+ /**
755
+ * Notifies Proxy to return segments information from query nodes.
756
+ *
757
+ * @param data
758
+ * | Property | Type | Description |
759
+ * | :---------------------- | :---- | :------------------------------- |
760
+ * | collectionName | String | The name of the collection to get segments info. |
761
+ *
762
+ *
763
+ *
764
+ * @return
765
+ * | Property | Description |
766
+ * | :-----------| :------------------------------- |
767
+ * | status | { error_code: number,reason:string } |
768
+ * | infos | QuerySegmentInfo is the growing segments's information in query cluster. |
769
+ *
770
+ *
771
+ * #### Example
772
+ *
773
+ * ```
774
+ * const res = await dataManager.getQuerySegmentInfo({
775
+ * collectionName: COLLECTION,
776
+ * });
777
+ * ```
778
+ */
779
+ Data.prototype.getQuerySegmentInfo = function (data) {
780
+ return __awaiter(this, void 0, void 0, function () {
781
+ var res;
782
+ return __generator(this, function (_a) {
783
+ switch (_a.label) {
784
+ case 0:
785
+ if (!data || !data.collectionName) {
786
+ throw new Error(ErrorReason_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
787
+ }
788
+ return [4 /*yield*/, utils_1.promisify(this.client, "GetQuerySegmentInfo", data)];
789
+ case 1:
790
+ res = _a.sent();
791
+ return [2 /*return*/, res];
792
+ }
793
+ });
794
+ });
795
+ };
513
796
  return Data;
514
797
  }(Client_1.Client));
515
798
  exports.Data = Data;