@zilliz/milvus2-sdk-node 2.2.9 → 2.2.11

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 (149) hide show
  1. package/README.md +76 -12
  2. package/dist/milvus/MilvusClient.d.ts +21 -2
  3. package/dist/milvus/MilvusClient.js +35 -29
  4. package/dist/milvus/MilvusClient.js.map +1 -1
  5. package/dist/milvus/OrmClient.d.ts +19 -0
  6. package/dist/milvus/OrmClient.js +77 -0
  7. package/dist/milvus/OrmClient.js.map +1 -0
  8. package/dist/milvus/const/ErrorReason.d.ts +36 -31
  9. package/dist/milvus/const/ErrorReason.js +39 -32
  10. package/dist/milvus/const/ErrorReason.js.map +1 -1
  11. package/dist/milvus/const/Milvus.d.ts +2 -9
  12. package/dist/milvus/const/Milvus.js +16 -33
  13. package/dist/milvus/const/Milvus.js.map +1 -1
  14. package/dist/milvus/const/client.d.ts +5 -0
  15. package/dist/milvus/const/client.js +10 -0
  16. package/dist/milvus/const/client.js.map +1 -0
  17. package/dist/milvus/const/defaults.d.ts +11 -0
  18. package/dist/milvus/const/defaults.js +16 -0
  19. package/dist/milvus/const/defaults.js.map +1 -0
  20. package/dist/milvus/const/highLevel.d.ts +23 -0
  21. package/dist/milvus/const/highLevel.js +26 -0
  22. package/dist/milvus/const/highLevel.js.map +1 -0
  23. package/dist/milvus/const/index.d.ts +5 -0
  24. package/dist/milvus/{types.js → const/index.js} +7 -10
  25. package/dist/milvus/const/index.js.map +1 -0
  26. package/dist/milvus/const/limits.d.ts +2 -0
  27. package/dist/milvus/const/limits.js +7 -0
  28. package/dist/milvus/const/limits.js.map +1 -0
  29. package/dist/milvus/{BaseClient.d.ts → grpc/BaseClient.d.ts} +20 -8
  30. package/dist/milvus/grpc/BaseClient.js +83 -0
  31. package/dist/milvus/grpc/BaseClient.js.map +1 -0
  32. package/dist/milvus/{Collection.d.ts → grpc/Collection.d.ts} +32 -3
  33. package/dist/milvus/grpc/Collection.js +786 -0
  34. package/dist/milvus/grpc/Collection.js.map +1 -0
  35. package/dist/milvus/{Data.d.ts → grpc/Data.d.ts} +68 -10
  36. package/dist/milvus/grpc/Data.js +880 -0
  37. package/dist/milvus/grpc/Data.js.map +1 -0
  38. package/dist/milvus/grpc/Database.d.ts +69 -0
  39. package/dist/milvus/grpc/Database.js +98 -0
  40. package/dist/milvus/grpc/Database.js.map +1 -0
  41. package/dist/milvus/grpc/GrpcClient.d.ts +46 -0
  42. package/dist/milvus/grpc/GrpcClient.js +150 -0
  43. package/dist/milvus/grpc/GrpcClient.js.map +1 -0
  44. package/dist/milvus/{MilvusIndex.d.ts → grpc/MilvusIndex.d.ts} +1 -1
  45. package/dist/milvus/grpc/MilvusIndex.js +203 -0
  46. package/dist/milvus/grpc/MilvusIndex.js.map +1 -0
  47. package/dist/milvus/{Partition.d.ts → grpc/Partition.d.ts} +1 -1
  48. package/dist/milvus/grpc/Partition.js +265 -0
  49. package/dist/milvus/grpc/Partition.js.map +1 -0
  50. package/dist/milvus/{Resource.d.ts → grpc/Resource.d.ts} +2 -2
  51. package/dist/milvus/grpc/Resource.js +250 -0
  52. package/dist/milvus/grpc/Resource.js.map +1 -0
  53. package/dist/milvus/{User.d.ts → grpc/User.d.ts} +1 -1
  54. package/dist/milvus/grpc/User.js +619 -0
  55. package/dist/milvus/grpc/User.js.map +1 -0
  56. package/dist/milvus/index.d.ts +4 -13
  57. package/dist/milvus/index.js +6 -14
  58. package/dist/milvus/index.js.map +1 -1
  59. package/dist/milvus/orm/Collection.d.ts +45 -0
  60. package/dist/milvus/orm/Collection.js +172 -0
  61. package/dist/milvus/orm/Collection.js.map +1 -0
  62. package/dist/milvus/orm/index.d.ts +2 -0
  63. package/dist/milvus/orm/index.js +19 -0
  64. package/dist/milvus/orm/index.js.map +1 -0
  65. package/dist/milvus/orm/utils.d.ts +27 -0
  66. package/dist/milvus/orm/utils.js +27 -0
  67. package/dist/milvus/orm/utils.js.map +1 -0
  68. package/dist/milvus/types/Client.d.ts +12 -1
  69. package/dist/milvus/types/Collection.d.ts +18 -4
  70. package/dist/milvus/types/Common.d.ts +1 -1
  71. package/dist/milvus/types/Data.d.ts +41 -5
  72. package/dist/milvus/types/Database.d.ts +12 -0
  73. package/dist/milvus/types/{Index.js → Database.js} +1 -1
  74. package/dist/milvus/types/Database.js.map +1 -0
  75. package/dist/milvus/types/HighLevel.d.ts +13 -0
  76. package/dist/milvus/types/HighLevel.js +3 -0
  77. package/dist/milvus/types/HighLevel.js.map +1 -0
  78. package/dist/milvus/types/{Index.d.ts → MilvusIndex.d.ts} +3 -2
  79. package/dist/milvus/types/MilvusIndex.js +3 -0
  80. package/dist/milvus/types/MilvusIndex.js.map +1 -0
  81. package/dist/milvus/types/Resource.d.ts +1 -1
  82. package/dist/milvus/types/User.d.ts +1 -1
  83. package/dist/milvus/types/index.d.ts +12 -0
  84. package/dist/milvus/types/index.js +30 -0
  85. package/dist/milvus/types/index.js.map +1 -0
  86. package/dist/{utils → milvus/utils}/Blob.js +4 -4
  87. package/dist/milvus/utils/Blob.js.map +1 -0
  88. package/dist/{utils → milvus/utils}/Format.d.ts +66 -2
  89. package/dist/milvus/utils/Format.js +416 -0
  90. package/dist/milvus/utils/Format.js.map +1 -0
  91. package/dist/{utils → milvus/utils}/Function.d.ts +1 -1
  92. package/dist/{utils → milvus/utils}/Function.js +7 -7
  93. package/dist/milvus/utils/Function.js.map +1 -0
  94. package/dist/{utils → milvus/utils}/Grpc.d.ts +9 -8
  95. package/dist/milvus/utils/Grpc.js +190 -0
  96. package/dist/milvus/utils/Grpc.js.map +1 -0
  97. package/dist/{utils → milvus/utils}/Validate.d.ts +7 -1
  98. package/dist/milvus/utils/Validate.js +140 -0
  99. package/dist/milvus/utils/Validate.js.map +1 -0
  100. package/dist/{utils → milvus/utils}/index.d.ts +2 -0
  101. package/dist/{utils → milvus/utils}/index.js +2 -0
  102. package/dist/milvus/utils/index.js.map +1 -0
  103. package/dist/milvus/utils/logger.d.ts +1 -0
  104. package/dist/milvus/utils/logger.js +18 -0
  105. package/dist/milvus/utils/logger.js.map +1 -0
  106. package/dist/proto/proto/common.proto +38 -14
  107. package/dist/proto/proto/google/protobuf/descriptor.proto +8 -4
  108. package/dist/proto/proto/milvus.proto +86 -83
  109. package/dist/proto/proto/schema.proto +5 -0
  110. package/dist/sdk.json +1 -1
  111. package/package.json +14 -11
  112. package/dist/milvus/BaseClient.js +0 -62
  113. package/dist/milvus/BaseClient.js.map +0 -1
  114. package/dist/milvus/Collection.js +0 -960
  115. package/dist/milvus/Collection.js.map +0 -1
  116. package/dist/milvus/Data.js +0 -909
  117. package/dist/milvus/Data.js.map +0 -1
  118. package/dist/milvus/GrpcClient.d.ts +0 -32
  119. package/dist/milvus/GrpcClient.js +0 -236
  120. package/dist/milvus/GrpcClient.js.map +0 -1
  121. package/dist/milvus/MilvusIndex.js +0 -299
  122. package/dist/milvus/MilvusIndex.js.map +0 -1
  123. package/dist/milvus/Partition.js +0 -369
  124. package/dist/milvus/Partition.js.map +0 -1
  125. package/dist/milvus/Resource.js +0 -356
  126. package/dist/milvus/Resource.js.map +0 -1
  127. package/dist/milvus/User.js +0 -806
  128. package/dist/milvus/User.js.map +0 -1
  129. package/dist/milvus/Utils.d.ts +0 -1
  130. package/dist/milvus/Utils.js +0 -8
  131. package/dist/milvus/Utils.js.map +0 -1
  132. package/dist/milvus/types/Index.js.map +0 -1
  133. package/dist/milvus/types.d.ts +0 -9
  134. package/dist/milvus/types.js.map +0 -1
  135. package/dist/proto/proto/feder.proto +0 -40
  136. package/dist/proto/proto/msg.proto +0 -107
  137. package/dist/utils/Blob.js.map +0 -1
  138. package/dist/utils/Format.js +0 -252
  139. package/dist/utils/Format.js.map +0 -1
  140. package/dist/utils/Function.js.map +0 -1
  141. package/dist/utils/Grpc.js +0 -170
  142. package/dist/utils/Grpc.js.map +0 -1
  143. package/dist/utils/Validate.js +0 -124
  144. package/dist/utils/Validate.js.map +0 -1
  145. package/dist/utils/index.js.map +0 -1
  146. package/dist/utils/test.d.ts +0 -15
  147. package/dist/utils/test.js +0 -98
  148. package/dist/utils/test.js.map +0 -1
  149. /package/dist/{utils → milvus/utils}/Blob.d.ts +0 -0
@@ -1,960 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
44
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
- var __rest = (this && this.__rest) || function (s, e) {
65
- var t = {};
66
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
- t[p] = s[p];
68
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
- t[p[i]] = s[p[i]];
72
- }
73
- return t;
74
- };
75
- Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.Collection = void 0;
77
- var utils_1 = require("../utils");
78
- var BaseClient_1 = require("./BaseClient");
79
- var _1 = require(".");
80
- var utils_2 = require("../utils");
81
- /**
82
- * @see [collection operation examples](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Collection.ts)
83
- */
84
- var Collection = /** @class */ (function (_super) {
85
- __extends(Collection, _super);
86
- function Collection() {
87
- return _super !== null && _super.apply(this, arguments) || this;
88
- }
89
- /**
90
- * Create a collection in Milvus.
91
- *
92
- * @param data
93
- * | Property | Type | Description |
94
- * | :-- | :-- | :-- |
95
- * | collection_name | String | Collection name |
96
- * | description | String | Collection description |
97
- * | consistency_level | String | "Strong"(Milvus default) | "Session" | "Bounded"| "Eventually" | "Customized"; |
98
- * | fields | <a href="https://github.com/milvus-io/milvus-sdk-node/blob/main/milvus/types/Collection.ts#L8" target="_blank">FieldType</a> | Field data |
99
- * | 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 |
100
- *
101
- * @returns
102
- * | Property | Description |
103
- * | :-- | :-- |
104
- * | error_code | Error code number |
105
- * | reason | Error cause |
106
- *
107
- * #### Example
108
- *
109
- * ```
110
- * new milvusClient(MILUVS_ADDRESS).createCollection({
111
- * collection_name: 'my_collection',
112
- * fields: [
113
- * {
114
- * name: "vector_01",
115
- * description: "vector field",
116
- * data_type: DataType.FloatVect,
117
- * type_params: {
118
- * dim: "8"
119
- * }
120
- * },
121
- * {
122
- * name: "age",
123
- * data_type: DataType.Int64,
124
- * autoID: true,
125
- * is_primary_key: true,
126
- * description: "",
127
- * },
128
- * ],
129
- * });
130
- * ```
131
- */
132
- Collection.prototype.createCollection = function (data) {
133
- var _a;
134
- return __awaiter(this, void 0, void 0, function () {
135
- var _b, fields, collection_name, description, _c, consistency_level, CollectionSchema, FieldSchema, payload, collectionParams, schemaBytes, level, promise;
136
- return __generator(this, function (_d) {
137
- switch (_d.label) {
138
- case 0:
139
- _b = data || {}, fields = _b.fields, collection_name = _b.collection_name, description = _b.description, _c = _b.consistency_level, consistency_level = _c === void 0 ? 'Bounded' : _c;
140
- // Check if fields and collection_name are present, otherwise throw an error.
141
- if (!(fields === null || fields === void 0 ? void 0 : fields.length) || !collection_name) {
142
- throw new Error(_1.ERROR_REASONS.CREATE_COLLECTION_CHECK_PARAMS);
143
- }
144
- // Check if the fields are valid.
145
- (0, utils_1.checkCollectionFields)(fields);
146
- CollectionSchema = this.schemaProto.lookupType('milvus.proto.schema.CollectionSchema');
147
- FieldSchema = this.schemaProto.lookupType('milvus.proto.schema.FieldSchema');
148
- payload = {
149
- name: collection_name,
150
- description: description || '',
151
- fields: fields.map(function (field) {
152
- // Assign the typeParams property to the result of parseToKeyValue(type_params).
153
- var _a = (0, utils_2.assignTypeParams)(field), type_params = _a.type_params, rest = __rest(_a, ["type_params"]);
154
- return FieldSchema.create(__assign(__assign({}, rest), { typeParams: (0, utils_1.parseToKeyValue)(type_params), dataType: field.data_type, isPrimaryKey: field.is_primary_key }));
155
- }),
156
- };
157
- collectionParams = CollectionSchema.create(payload);
158
- schemaBytes = CollectionSchema.encode(collectionParams).finish();
159
- level = (_a = _1.ConsistencyLevelEnum[consistency_level]) !== null && _a !== void 0 ? _a : _1.ConsistencyLevelEnum.Bounded;
160
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateCollection', __assign(__assign({}, data), { schema: schemaBytes, consistency_level: level }), data.timeout || this.timeout)];
161
- case 1:
162
- promise = _d.sent();
163
- // Return the promise.
164
- return [2 /*return*/, promise];
165
- }
166
- });
167
- });
168
- };
169
- /**
170
- * Check if a collection exists.
171
- *
172
- * @param data
173
- * | Property | Type | Description |
174
- * | :-- | :-- | :-- |
175
- * | collection_name | String | Collection name |
176
- * | 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 |
177
- *
178
- * @returns
179
- * | Property | Description |
180
- * | :-- | :-- |
181
- * | status | { error_code: number, reason: string } |
182
- * | value | `true` or `false` |
183
-
184
- *
185
- * #### Example
186
- *
187
- * ```
188
- * new milvusClient(MILUVS_ADDRESS).hasCollection({
189
- * collection_name: 'my_collection',
190
- * });
191
- * ```
192
- */
193
- Collection.prototype.hasCollection = function (data) {
194
- return __awaiter(this, void 0, void 0, function () {
195
- var promise;
196
- return __generator(this, function (_a) {
197
- switch (_a.label) {
198
- case 0:
199
- (0, utils_1.checkCollectionName)(data);
200
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'HasCollection', data, data.timeout || this.timeout)];
201
- case 1:
202
- promise = _a.sent();
203
- return [2 /*return*/, promise];
204
- }
205
- });
206
- });
207
- };
208
- /**
209
- * List all collections or get collection loading status.
210
- *
211
- * @param data
212
- * | Property | Type | Description |
213
- * | :-- | :-- | :-- |
214
- * | type(optional) | enum | All -> 0, Loaded -> 1 |
215
- * | collection_names(optional) | String[] | If `type = Loaded`, Milvus will return `collection_names inMemory_percentages` |
216
- * | 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 |
217
-
218
- *
219
- * @returns
220
- * | Property | Description |
221
- * | :-- | :-- |
222
- * | status | { error_code: number, reason: string } |
223
- * | data | Contains collection name, ID , timestamp (UTC created time), and loadedPercentage (100 means loaded) |
224
- *
225
- *
226
- * #### Example
227
- *
228
- * ```
229
- * new milvusClient(MILUVS_ADDRESS).showCollections();
230
- * ```
231
- */
232
- Collection.prototype.showCollections = function (data) {
233
- return __awaiter(this, void 0, void 0, function () {
234
- var promise, result;
235
- return __generator(this, function (_a) {
236
- switch (_a.label) {
237
- case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ShowCollections', {
238
- type: data ? data.type : _1.ShowCollectionsType.All,
239
- collection_names: (data === null || data === void 0 ? void 0 : data.collection_names) || [],
240
- }, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout)];
241
- case 1:
242
- promise = _a.sent();
243
- result = [];
244
- promise.collection_names.forEach(function (name, index) {
245
- result.push({
246
- name: name,
247
- id: promise.collection_ids[index],
248
- timestamp: promise.created_utc_timestamps[index],
249
- loadedPercentage: promise.inMemory_percentages[index],
250
- });
251
- });
252
- promise.data = result;
253
- return [2 /*return*/, promise];
254
- }
255
- });
256
- });
257
- };
258
- /**
259
- * Show the details of a collection, e.g. name, schema.
260
- *
261
- * @param data
262
- * | Property | Type | Description |
263
- * | :-- | :-- | :-- |
264
- * | collection_name | String | Collection name |
265
- * | 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 |
266
- *
267
- * @returns
268
- * | Property | Description |
269
- * | :-- | :-- |
270
- * | status | { error_code: number, reason: string } |
271
- * | schema | Information of all fields in this collection |
272
- * | collectionID | Collection ID |
273
- *
274
- *
275
- * #### Example
276
- *
277
- * ```
278
- * new milvusClient(MILUVS_ADDRESS).describeCollection({
279
- * collection_name: 'my_collection',
280
- * });
281
- * ```
282
- */
283
- Collection.prototype.describeCollection = function (data) {
284
- return __awaiter(this, void 0, void 0, function () {
285
- var promise;
286
- return __generator(this, function (_a) {
287
- switch (_a.label) {
288
- case 0:
289
- (0, utils_1.checkCollectionName)(data);
290
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DescribeCollection', data, data.timeout || this.timeout)];
291
- case 1:
292
- promise = _a.sent();
293
- return [2 /*return*/, promise];
294
- }
295
- });
296
- });
297
- };
298
- /**
299
- * Show the statistics information of a collection.
300
- *
301
- * @param data
302
- * | Property | Type | Description |
303
- * | :-- | :-- | :-- |
304
- * | collection_name | String | Collection name |
305
- * | 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 |
306
- *
307
- * @returns
308
- * | Property | Description |
309
- * | :-- | :-- |
310
- * | status | { error_code: number, reason: string } |
311
- * | stats | [{key: string, value: string}] |
312
- * | data | Transform **stats** to { row_count: 0 } |
313
- *
314
- *
315
- * #### Example
316
- *
317
- * ```
318
- * new milvusClient(MILUVS_ADDRESS).getCollectionStatistics({
319
- * collection_name: 'my_collection',
320
- * });
321
- * ```
322
- */
323
- Collection.prototype.getCollectionStatistics = function (data) {
324
- return __awaiter(this, void 0, void 0, function () {
325
- var promise;
326
- return __generator(this, function (_a) {
327
- switch (_a.label) {
328
- case 0:
329
- (0, utils_1.checkCollectionName)(data);
330
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCollectionStatistics', data, data.timeout || this.timeout)];
331
- case 1:
332
- promise = _a.sent();
333
- promise.data = (0, utils_1.formatKeyValueData)(promise.stats, ['row_count']);
334
- return [2 /*return*/, promise];
335
- }
336
- });
337
- });
338
- };
339
- /**
340
- * Load collection data into query nodes, then you can do vector search on this collection.
341
- * It's async function, but we can use showCollections to check loading status.
342
- *
343
- * @param data
344
- * | Property | Type | Description |
345
- * | :--- | :-- | :-- |
346
- * | collection_name | String | Collection name |
347
- * | replica_number? | number | replica number |
348
- * | resource_groups? | String[] | resource group names |
349
- * | 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 |
350
- *
351
- * @returns
352
- * | Property | Description |
353
- * | :-- | :-- |
354
- * | error_code | Error code number |
355
- * | reason | Error cause |
356
- *
357
- * #### Example
358
- *
359
- * ```
360
- * new milvusClient(MILUVS_ADDRESS).loadCollection({
361
- * collection_name: 'my_collection',
362
- * });
363
- * ```
364
- */
365
- Collection.prototype.loadCollection = function (data) {
366
- return __awaiter(this, void 0, void 0, function () {
367
- var promise;
368
- return __generator(this, function (_a) {
369
- switch (_a.label) {
370
- case 0:
371
- (0, utils_1.checkCollectionName)(data);
372
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout || this.timeout)];
373
- case 1:
374
- promise = _a.sent();
375
- return [2 /*return*/, promise];
376
- }
377
- });
378
- });
379
- };
380
- /**
381
- * Same function with loadCollection, but it's sync function.
382
- * Help to ensure this collection is loaded.
383
- *
384
- * @param data
385
- * | Property | Type | Description |
386
- * | :--- | :-- | :-- |
387
- * | collection_name | String | Collection name |
388
- * | replica_number? | number | replica number |
389
- * | resource_groups? | String[] | resource group |
390
- * | 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 |
391
- *
392
- * @returns
393
- * | Property | Description |
394
- * | :-- | :-- |
395
- * | error_code | Error code number |
396
- * | reason | Error cause |
397
- *
398
- * #### Example
399
- *
400
- * ```
401
- * new milvusClient(MILUVS_ADDRESS).loadCollectionSync({
402
- * collection_name: 'my_collection',
403
- * });
404
- * ```
405
- */
406
- Collection.prototype.loadCollectionSync = function (data) {
407
- return __awaiter(this, void 0, void 0, function () {
408
- var promise, loadedPercentage, res;
409
- return __generator(this, function (_a) {
410
- switch (_a.label) {
411
- case 0:
412
- (0, utils_1.checkCollectionName)(data);
413
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadCollection', data, data.timeout || this.timeout)];
414
- case 1:
415
- promise = _a.sent();
416
- if (promise.error_code !== _1.ErrorCode.SUCCESS) {
417
- throw new Error("ErrorCode: ".concat(promise.error_code, ". Reason: ").concat(promise.reason));
418
- }
419
- loadedPercentage = 0;
420
- _a.label = 2;
421
- case 2:
422
- if (!(Number(loadedPercentage) < 100)) return [3 /*break*/, 5];
423
- return [4 /*yield*/, this.getLoadingProgress({
424
- collection_name: data.collection_name,
425
- })];
426
- case 3:
427
- res = _a.sent();
428
- if (res.status.error_code !== _1.ErrorCode.SUCCESS) {
429
- throw new Error("ErrorCode: ".concat(res.status.error_code, ". Reason: ").concat(res.status.reason));
430
- }
431
- loadedPercentage = Number(res.progress);
432
- // sleep 400ms
433
- return [4 /*yield*/, (0, utils_1.sleep)(400)];
434
- case 4:
435
- // sleep 400ms
436
- _a.sent();
437
- return [3 /*break*/, 2];
438
- case 5: return [2 /*return*/, promise];
439
- }
440
- });
441
- });
442
- };
443
- /**
444
- * Release a collection from cache to reduce cache usage.
445
- * Note that you cannot search while the corresponding collection is unloaded.
446
- *
447
- * @param data
448
- * | Property | Type | Description |
449
- * | :-- | :-- | :-- |
450
- * | collection_name | String | Collection name |
451
- * | 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 |
452
- *
453
- * @returns
454
- * | Property | Description |
455
- * | :-- | :-- |
456
- * | error_code | Error code number |
457
- * | reason | Error cause |
458
- *
459
- * #### Example
460
- *
461
- * ```
462
- * new milvusClient(MILUVS_ADDRESS).releaseCollection({
463
- * collection_name: 'my_collection',
464
- * });
465
- * ```
466
- */
467
- Collection.prototype.releaseCollection = function (data) {
468
- return __awaiter(this, void 0, void 0, function () {
469
- var promise;
470
- return __generator(this, function (_a) {
471
- switch (_a.label) {
472
- case 0:
473
- (0, utils_1.checkCollectionName)(data);
474
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ReleaseCollection', data, data.timeout || this.timeout)];
475
- case 1:
476
- promise = _a.sent();
477
- return [2 /*return*/, promise];
478
- }
479
- });
480
- });
481
- };
482
- /**
483
- * Rename a collection
484
- *
485
- * @param data
486
- * | Property | Type | Description |
487
- * | :-- | :-- | :-- |
488
- * | collection_name | String | old collection name |
489
- * | new_collection_name | String | new collection name |
490
- * | 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 |
491
- *
492
- * @returns
493
- * | Property | Description |
494
- * | :-- | :-- |
495
- * | error_code | Error code number |
496
- * | reason | Error cause |
497
- *
498
- * #### Example
499
- *
500
- * ```
501
- * new milvusClient(MILUVS_ADDRESS).renameCollection({
502
- * collection_name: 'my_collection',
503
- * new_collection_name: 'my_new_collection'
504
- * });
505
- * ```
506
- */
507
- Collection.prototype.renameCollection = function (data) {
508
- return __awaiter(this, void 0, void 0, function () {
509
- var promise;
510
- return __generator(this, function (_a) {
511
- switch (_a.label) {
512
- case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'RenameCollection', {
513
- oldName: data.collection_name,
514
- newName: data.new_collection_name,
515
- }, data.timeout || this.timeout)];
516
- case 1:
517
- promise = _a.sent();
518
- return [2 /*return*/, promise];
519
- }
520
- });
521
- });
522
- };
523
- /**
524
- * Drop a collection. Note that this drops all data in the collection.
525
- *
526
- * @param data
527
- * | Property | Type | Description |
528
- * | :-- | :-- | :-- |
529
- * | collection_name | String | Collection name |
530
- * | 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. |
531
- *
532
- * @returns
533
- * | Property | Description |
534
- * | :-- | :-- |
535
- * | error_code | Error code number |
536
- * | reason | Error cause |
537
- *
538
- * #### Example
539
- *
540
- * ```
541
- * new milvusClient(MILUVS_ADDRESS).dropCollection({
542
- * collection_name: 'my_collection',
543
- * });
544
- * ```
545
- */
546
- Collection.prototype.dropCollection = function (data) {
547
- return __awaiter(this, void 0, void 0, function () {
548
- var promise;
549
- return __generator(this, function (_a) {
550
- switch (_a.label) {
551
- case 0:
552
- (0, utils_1.checkCollectionName)(data);
553
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropCollection', data, data.timeout || this.timeout)];
554
- case 1:
555
- promise = _a.sent();
556
- return [2 /*return*/, promise];
557
- }
558
- });
559
- });
560
- };
561
- /**
562
- * Create collection alias, then you can use alias instead of collection_name when you do vector search
563
- *
564
- * @param data
565
- * | Property | Type | Description |
566
- * | :-- | :-- | :-- |
567
- * | alias | String | alias name |
568
- * | collection_name | String | Collection name |
569
- * | 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. |
570
- *
571
- * @returns
572
- * | Property | Description |
573
- * | :-- | :-- |
574
- * | error_code | Error code number |
575
- * | reason | Error cause |
576
- *
577
- *
578
- * #### Example
579
- *
580
- * ```
581
- * new milvusClient(MILUVS_ADDRESS).createAlias({
582
- * alias: 'my_collection_alis',
583
- * collection_name: 'my_collection',
584
- * });
585
- * ```
586
- */
587
- Collection.prototype.createAlias = function (data) {
588
- return __awaiter(this, void 0, void 0, function () {
589
- var promise;
590
- return __generator(this, function (_a) {
591
- switch (_a.label) {
592
- case 0:
593
- (0, utils_1.checkCollectionName)(data);
594
- if (!data.alias) {
595
- throw new Error(_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
596
- }
597
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'CreateAlias', data, data.timeout || this.timeout)];
598
- case 1:
599
- promise = _a.sent();
600
- return [2 /*return*/, promise];
601
- }
602
- });
603
- });
604
- };
605
- /**
606
- * Drop a collection alias
607
- *
608
- * @param data
609
- * | Property | Type | Description |
610
- * | :-- | :-- | :-- |
611
- * | alias | String | alias name |
612
- * | collection_name | String | Collection name |
613
- * | 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. |
614
- *
615
- * @returns
616
- * | Property | Description |
617
- * | :-- | :-- |
618
- * | error_code | Error code number |
619
- * | reason | Error cause |
620
- *
621
- *
622
- * #### Example
623
- *
624
- * ```
625
- * new milvusClient(MILUVS_ADDRESS).dropAlias({
626
- * alias: 'my_collection_alis',
627
- * collection_name: 'my_collection',
628
- * });
629
- * ```
630
- */
631
- Collection.prototype.dropAlias = function (data) {
632
- return __awaiter(this, void 0, void 0, function () {
633
- var promise;
634
- return __generator(this, function (_a) {
635
- switch (_a.label) {
636
- case 0:
637
- if (!data.alias) {
638
- throw new Error(_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
639
- }
640
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'DropAlias', data, data.timeout || this.timeout)];
641
- case 1:
642
- promise = _a.sent();
643
- return [2 /*return*/, promise];
644
- }
645
- });
646
- });
647
- };
648
- /**
649
- * alter a collection alias
650
- *
651
- * @param data
652
- * | Property | Type | Description |
653
- * | :-- | :-- | :-- |
654
- * | alias | String | alias name |
655
- * | collection_name | String | Collection name |
656
- * | 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. |
657
- *
658
- * @returns
659
- * | Property | Description |
660
- * | :-- | :-- |
661
- * | error_code | Error code number |
662
- * | reason | Error cause |
663
- *
664
- *
665
- * #### Example
666
- *
667
- * ```
668
- * new milvusClient(MILUVS_ADDRESS).alterAlais({
669
- * alias: 'my_collection_alis',
670
- * collection_name: 'my_collection',
671
- * });
672
- * ```
673
- */
674
- Collection.prototype.alterAlias = function (data) {
675
- return __awaiter(this, void 0, void 0, function () {
676
- var promise;
677
- return __generator(this, function (_a) {
678
- switch (_a.label) {
679
- case 0:
680
- (0, utils_1.checkCollectionName)(data);
681
- if (!data.alias) {
682
- throw new Error(_1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
683
- }
684
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'AlterAlias', data, data.timeout || this.timeout)];
685
- case 1:
686
- promise = _a.sent();
687
- return [2 /*return*/, promise];
688
- }
689
- });
690
- });
691
- };
692
- /**
693
- * Do compaction for the collection.
694
- *
695
- * @param data
696
- * | Property | Type | Description |
697
- * | :-- | :-- | :-- |
698
- * | collection_name | String | The collection name to compact |
699
- * | 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 |
700
- *
701
- * @returns
702
- * | Property | Description |
703
- * | :-- | :-- |
704
- * | status | { error_code: number, reason: string } |
705
- * | compactionID | compaction ID |
706
- *
707
- * #### Example
708
- *
709
- * ```
710
- * new milvusClient(MILUVS_ADDRESS).compact({
711
- * collection_name: 'my_collection',
712
- * });
713
- * ```
714
- */
715
- Collection.prototype.compact = function (data) {
716
- return __awaiter(this, void 0, void 0, function () {
717
- var collectionInfo, res;
718
- return __generator(this, function (_a) {
719
- switch (_a.label) {
720
- case 0:
721
- (0, utils_1.checkCollectionName)(data);
722
- return [4 /*yield*/, this.describeCollection(data)];
723
- case 1:
724
- collectionInfo = _a.sent();
725
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ManualCompaction', {
726
- collectionID: collectionInfo.collectionID,
727
- }, data.timeout || this.timeout)];
728
- case 2:
729
- res = _a.sent();
730
- return [2 /*return*/, res];
731
- }
732
- });
733
- });
734
- };
735
- /**
736
- * Get compaction states of a targeted compaction id
737
- *
738
- * @param data
739
- * | Property | Type | Description |
740
- * | :-- | :-- | :-- |
741
- * | compactionID | number or string | the id returned by compact |
742
- * | 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 |
743
- *
744
- * @returns
745
- * | Property | Description |
746
- * | :-- | :-- |
747
- * | status | { error_code: number, reason: string } |
748
- * | state | the state of the compaction |
749
- *
750
- * #### Example
751
- *
752
- * ```
753
- * new milvusClient(MILUVS_ADDRESS).getCompactionState({
754
- * compactionID: compactionID,
755
- * });
756
- * ```
757
- */
758
- Collection.prototype.getCompactionState = function (data) {
759
- return __awaiter(this, void 0, void 0, function () {
760
- var res;
761
- return __generator(this, function (_a) {
762
- switch (_a.label) {
763
- case 0:
764
- if (!data || !data.compactionID) {
765
- throw new Error(_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
766
- }
767
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionState', data, data.timeout || this.timeout)];
768
- case 1:
769
- res = _a.sent();
770
- return [2 /*return*/, res];
771
- }
772
- });
773
- });
774
- };
775
- /**
776
- * Get compaction states of a targeted compaction id
777
- *
778
- * @param data
779
- * | Property | Type | Description |
780
- * | :-- | :-- | :-- |
781
- * | compactionID | number or string | the id returned by compact |
782
- * | 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 |
783
- *
784
- * @returns
785
- * | Property | Description |
786
- * | :-- | :-- |
787
- * | status | { error_code: number, reason: string } |
788
- * | state | the state of the compaction |
789
- *
790
- * #### Example
791
- *
792
- * ```
793
- * new milvusClient(MILUVS_ADDRESS).getCompactionStateWithPlans({
794
- * compactionID: compactionID,
795
- * });
796
- * ```
797
- */
798
- Collection.prototype.getCompactionStateWithPlans = function (data) {
799
- return __awaiter(this, void 0, void 0, function () {
800
- var res;
801
- return __generator(this, function (_a) {
802
- switch (_a.label) {
803
- case 0:
804
- if (!data || !data.compactionID) {
805
- throw new Error(_1.ERROR_REASONS.COMPACTIONID_IS_REQUIRED);
806
- }
807
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetCompactionStateWithPlans', data, data.timeout || this.timeout)];
808
- case 1:
809
- res = _a.sent();
810
- return [2 /*return*/, res];
811
- }
812
- });
813
- });
814
- };
815
- /**
816
- * Get replicas
817
- *
818
- * @param data
819
- * | Property | Type | Description |
820
- * | :-- | :-- | :-- |
821
- * | collectionID | number or string | the id returned by compact |
822
- * | 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 |
823
- *
824
- * @returns
825
- * | Property | Description |
826
- * | :-- | :-- |
827
- * | status | { error_code: number, reason: string } |
828
- * | ReplicaInfo[] | replica info array |
829
- *
830
- * #### Example
831
- *
832
- * ```
833
- * new milvusClient(MILUVS_ADDRESS).getReplicas({
834
- * collectionID: collectionID,
835
- * });
836
- *
837
- * ```
838
- *
839
- * Return
840
- * ```
841
- * {
842
- * replicas: [
843
- * {
844
- * partition_ids: [Array],
845
- * shard_replicas: [Array],
846
- * node_ids: [Array],
847
- * replicaID: '436724291187770258',
848
- * collectionID: '436777253933154305'
849
- * }
850
- * ],
851
- * status: { error_code: 'Success', reason: '' }
852
- * }
853
- * ```
854
- */
855
- Collection.prototype.getReplicas = function (data) {
856
- return __awaiter(this, void 0, void 0, function () {
857
- var res;
858
- return __generator(this, function (_a) {
859
- switch (_a.label) {
860
- case 0:
861
- if (!data || !data.collectionID) {
862
- throw new Error(_1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
863
- }
864
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetReplicas', data, data.timeout || this.timeout)];
865
- case 1:
866
- res = _a.sent();
867
- return [2 /*return*/, res];
868
- }
869
- });
870
- });
871
- };
872
- /**
873
- * Get loading progress of a collection
874
- *
875
- * @param data
876
- * | Property | Type | Description |
877
- * | :-- | :-- | :-- |
878
- * | collection_name | string | the name of the collection |
879
- * | 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 |
880
- *
881
- * @returns
882
- * | Property | Description |
883
- * | :-- | :-- |
884
- * | status | { error_code: number, reason: string } |
885
- * | total_row_num | the total number of rows in the collection |
886
- * | total_loaded_row_num | the total number of loaded rows in the collection |
887
- *
888
- * @throws {Error} if `collection_name` property is not present in `data`
889
- *
890
- * #### Example
891
- *
892
- * ```
893
- * new milvusClient(MILUVS_ADDRESS).getLoadingProgress({
894
- * collection_name: 'my_collection',
895
- * });
896
- * ```
897
- */
898
- Collection.prototype.getLoadingProgress = function (data) {
899
- return __awaiter(this, void 0, void 0, function () {
900
- var res;
901
- return __generator(this, function (_a) {
902
- switch (_a.label) {
903
- case 0:
904
- if (!data || !data.collection_name) {
905
- throw new Error(_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
906
- }
907
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetLoadingProgress', data, data.timeout || this.timeout)];
908
- case 1:
909
- res = _a.sent();
910
- return [2 /*return*/, res];
911
- }
912
- });
913
- });
914
- };
915
- /**
916
- * Get the loading state of a collection
917
- *
918
- * @param data
919
- * | Property | Type | Description |
920
- * | :-- | :-- | :-- |
921
- * | collection_name | string | the name of the collection |
922
- * | 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 |
923
- *
924
- * @returns
925
- * | Property | Description |
926
- * | :-- | :-- |
927
- * | status | { error_code: number, reason: string } |
928
- * | state | the loading state of the collection |
929
- *
930
- * @throws {Error} if `collection_name` property is not present in `data`
931
- *
932
- * #### Example
933
- *
934
- * ```
935
- * new milvusClient(MILUVS_ADDRESS).getLoadState({
936
- * collection_name: 'my_collection',
937
- * });
938
- * ```
939
- */
940
- Collection.prototype.getLoadState = function (data) {
941
- return __awaiter(this, void 0, void 0, function () {
942
- var res;
943
- return __generator(this, function (_a) {
944
- switch (_a.label) {
945
- case 0:
946
- if (!data || !data.collection_name) {
947
- throw new Error(_1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
948
- }
949
- return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetLoadState', data, data.timeout || this.timeout)];
950
- case 1:
951
- res = _a.sent();
952
- return [2 /*return*/, res];
953
- }
954
- });
955
- });
956
- };
957
- return Collection;
958
- }(BaseClient_1.BaseClient));
959
- exports.Collection = Collection;
960
- //# sourceMappingURL=Collection.js.map