@zilliz/milvus2-sdk-node 2.3.5 → 2.4.1
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.
- package/README.md +154 -35
- package/dist/milvus/HttpClient.d.ts +165 -2
- package/dist/milvus/HttpClient.js +17 -3
- package/dist/milvus/HttpClient.js.map +1 -1
- package/dist/milvus/MilvusClient.d.ts +3 -3
- package/dist/milvus/MilvusClient.js +42 -8
- package/dist/milvus/MilvusClient.js.map +1 -1
- package/dist/milvus/const/client.d.ts +4 -3
- package/dist/milvus/const/client.js +4 -3
- package/dist/milvus/const/client.js.map +1 -1
- package/dist/milvus/const/defaults.d.ts +5 -4
- package/dist/milvus/const/defaults.js +14 -13
- package/dist/milvus/const/defaults.js.map +1 -1
- package/dist/milvus/const/error.js +1 -1
- package/dist/milvus/const/error.js.map +1 -1
- package/dist/milvus/const/milvus.d.ts +47 -8
- package/dist/milvus/const/milvus.js +42 -3
- package/dist/milvus/const/milvus.js.map +1 -1
- package/dist/milvus/grpc/BaseClient.d.ts +11 -9
- package/dist/milvus/grpc/BaseClient.js +59 -21
- package/dist/milvus/grpc/BaseClient.js.map +1 -1
- package/dist/milvus/grpc/Collection.d.ts +311 -366
- package/dist/milvus/grpc/Collection.js +355 -387
- package/dist/milvus/grpc/Collection.js.map +1 -1
- package/dist/milvus/grpc/Data.d.ts +244 -291
- package/dist/milvus/grpc/Data.js +402 -539
- package/dist/milvus/grpc/Data.js.map +1 -1
- package/dist/milvus/grpc/Database.d.ts +29 -41
- package/dist/milvus/grpc/Database.js +32 -44
- package/dist/milvus/grpc/Database.js.map +1 -1
- package/dist/milvus/grpc/GrpcClient.d.ts +34 -13
- package/dist/milvus/grpc/GrpcClient.js +80 -70
- package/dist/milvus/grpc/GrpcClient.js.map +1 -1
- package/dist/milvus/grpc/MilvusIndex.d.ts +127 -67
- package/dist/milvus/grpc/MilvusIndex.js +166 -70
- package/dist/milvus/grpc/MilvusIndex.js.map +1 -1
- package/dist/milvus/grpc/Partition.d.ts +78 -113
- package/dist/milvus/grpc/Partition.js +109 -119
- package/dist/milvus/grpc/Partition.js.map +1 -1
- package/dist/milvus/grpc/Resource.d.ts +63 -92
- package/dist/milvus/grpc/Resource.js +69 -98
- package/dist/milvus/grpc/Resource.js.map +1 -1
- package/dist/milvus/grpc/User.d.ts +263 -295
- package/dist/milvus/grpc/User.js +287 -310
- package/dist/milvus/grpc/User.js.map +1 -1
- package/dist/milvus/http/Alias.d.ts +37 -0
- package/dist/milvus/http/Alias.js +62 -0
- package/dist/milvus/http/Alias.js.map +1 -0
- package/dist/milvus/http/Collection.d.ts +15 -1
- package/dist/milvus/http/Collection.js +55 -9
- package/dist/milvus/http/Collection.js.map +1 -1
- package/dist/milvus/http/Import.d.ts +33 -0
- package/dist/milvus/http/Import.js +48 -0
- package/dist/milvus/http/Import.js.map +1 -0
- package/dist/milvus/http/MilvusIndex.d.ts +35 -0
- package/dist/milvus/http/MilvusIndex.js +55 -0
- package/dist/milvus/http/MilvusIndex.js.map +1 -0
- package/dist/milvus/http/Partition.d.ts +41 -0
- package/dist/milvus/http/Partition.js +76 -0
- package/dist/milvus/http/Partition.js.map +1 -0
- package/dist/milvus/http/Role.d.ts +39 -0
- package/dist/milvus/http/Role.js +69 -0
- package/dist/milvus/http/Role.js.map +1 -0
- package/dist/milvus/http/User.d.ts +41 -0
- package/dist/milvus/http/User.js +76 -0
- package/dist/milvus/http/User.js.map +1 -0
- package/dist/milvus/http/Vector.d.ts +5 -3
- package/dist/milvus/http/Vector.js +10 -7
- package/dist/milvus/http/Vector.js.map +1 -1
- package/dist/milvus/http/index.d.ts +6 -0
- package/dist/milvus/http/index.js +6 -0
- package/dist/milvus/http/index.js.map +1 -1
- package/dist/milvus/index.d.ts +0 -1
- package/dist/milvus/index.js +0 -1
- package/dist/milvus/index.js.map +1 -1
- package/dist/milvus/types/Client.d.ts +5 -0
- package/dist/milvus/types/Collection.d.ts +34 -9
- package/dist/milvus/types/Common.d.ts +1 -3
- package/dist/milvus/types/Data.d.ts +79 -23
- package/dist/milvus/types/Data.js +1 -0
- package/dist/milvus/types/Data.js.map +1 -1
- package/dist/milvus/types/HighLevel.d.ts +6 -3
- package/dist/milvus/types/Http.d.ts +191 -9
- package/dist/milvus/types/MilvusIndex.d.ts +17 -3
- package/dist/milvus/utils/Bytes.d.ts +84 -0
- package/dist/milvus/utils/Bytes.js +261 -0
- package/dist/milvus/utils/Bytes.js.map +1 -0
- package/dist/milvus/utils/Format.d.ts +126 -68
- package/dist/milvus/utils/Format.js +375 -94
- package/dist/milvus/utils/Format.js.map +1 -1
- package/dist/milvus/utils/Function.d.ts +4 -2
- package/dist/milvus/utils/Function.js +58 -25
- package/dist/milvus/utils/Function.js.map +1 -1
- package/dist/milvus/utils/Grpc.d.ts +3 -2
- package/dist/milvus/utils/Grpc.js +65 -98
- package/dist/milvus/utils/Grpc.js.map +1 -1
- package/dist/milvus/utils/Validate.d.ts +18 -3
- package/dist/milvus/utils/Validate.js +38 -12
- package/dist/milvus/utils/Validate.js.map +1 -1
- package/dist/milvus/utils/index.d.ts +1 -1
- package/dist/milvus/utils/index.js +1 -1
- package/dist/milvus/utils/index.js.map +1 -1
- package/dist/proto/proto/common.proto +26 -1
- package/dist/proto/proto/google/protobuf/descriptor.proto +90 -28
- package/dist/proto/proto/milvus.proto +168 -2
- package/dist/proto/proto/rg.proto +28 -0
- package/dist/proto/proto/schema.proto +34 -0
- package/dist/sdk.json +1 -1
- package/package.json +8 -5
- package/dist/milvus/OrmClient.d.ts +0 -19
- package/dist/milvus/OrmClient.js +0 -51
- package/dist/milvus/OrmClient.js.map +0 -1
- package/dist/milvus/orm/Collection.d.ts +0 -43
- package/dist/milvus/orm/Collection.js +0 -165
- package/dist/milvus/orm/Collection.js.map +0 -1
- package/dist/milvus/orm/index.d.ts +0 -1
- package/dist/milvus/orm/index.js +0 -18
- package/dist/milvus/orm/index.js.map +0 -1
- package/dist/milvus/utils/Blob.d.ts +0 -4
- package/dist/milvus/utils/Blob.js +0 -18
- package/dist/milvus/utils/Blob.js.map +0 -1
|
@@ -32,33 +32,31 @@ class Collection extends Database_1.Database {
|
|
|
32
32
|
// alias
|
|
33
33
|
this.list_collections = this.showCollections;
|
|
34
34
|
// alias
|
|
35
|
-
this.drop_collection = this.dropCollection;
|
|
36
|
-
// alias
|
|
37
35
|
this.listCollections = this.showCollections;
|
|
36
|
+
// alias
|
|
37
|
+
this.getCollectionStats = this.getCollectionStatistics;
|
|
38
|
+
// alias
|
|
39
|
+
this.drop_collection = this.dropCollection;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @param data
|
|
43
|
-
* | Property | Type | Description |
|
|
44
|
-
* | :-- | :-- | :-- |
|
|
45
|
-
* | collection_name | String | Collection name |
|
|
46
|
-
* | description | String | Collection description |
|
|
47
|
-
* | num_partitions | number | number of partitions allowed |
|
|
48
|
-
* | consistency_level | String | "Strong"(Milvus default) | "Session" | "Bounded"| "Eventually" | "Customized"; |
|
|
49
|
-
* | fields | <a href="https://github.com/milvus-io/milvus-sdk-node/blob/main/milvus/types/Collection.ts#L8" target="_blank">FieldType</a> | Field data |
|
|
50
|
-
* | 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 |
|
|
42
|
+
* Creates a new collection in Milvus.
|
|
51
43
|
*
|
|
52
|
-
* @
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
44
|
+
* @param {CreateCollectionReq} data - The data for the new collection.
|
|
45
|
+
* @param {string} data.collection_name - The name of the new collection.
|
|
46
|
+
* @param {string} [data.description] - The description of the new collection.
|
|
47
|
+
* @param {number} [data.num_partitions] - The number of partitions allowed in the new collection.
|
|
48
|
+
* @param {string} [data.consistency_level] - The consistency level of the new collection. Can be "Strong" (Milvus default), "Session", "Bounded", "Eventually", or "Customized".
|
|
49
|
+
* @param {FieldType[]} data.fields - The fields of the new collection. See [FieldType](https://github.com/milvus-io/milvus-sdk-node/blob/main/milvus/types/Collection.ts#L8) for more details.
|
|
50
|
+
* @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.
|
|
57
51
|
*
|
|
58
|
-
*
|
|
52
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
53
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
54
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
59
55
|
*
|
|
56
|
+
* @example
|
|
60
57
|
* ```
|
|
61
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
58
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
59
|
+
* const resStatus = await milvusClient.createCollection({
|
|
62
60
|
* collection_name: 'my_collection',
|
|
63
61
|
* fields: [
|
|
64
62
|
* {
|
|
@@ -76,7 +74,7 @@ class Collection extends Database_1.Database {
|
|
|
76
74
|
* is_primary_key: true,
|
|
77
75
|
* description: "",
|
|
78
76
|
* },
|
|
79
|
-
*
|
|
77
|
+
* ],
|
|
80
78
|
* });
|
|
81
79
|
* ```
|
|
82
80
|
*/
|
|
@@ -84,7 +82,11 @@ class Collection extends Database_1.Database {
|
|
|
84
82
|
var _a;
|
|
85
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
84
|
// Destructure the data object and set default values for consistency_level and description.
|
|
87
|
-
const {
|
|
85
|
+
const { collection_name, consistency_level = data.consistency_level || 'Bounded', num_partitions, } = data || {};
|
|
86
|
+
let fields = data.fields;
|
|
87
|
+
if (data.schema) {
|
|
88
|
+
fields = data.schema;
|
|
89
|
+
}
|
|
88
90
|
// Check if fields and collection_name are present, otherwise throw an error.
|
|
89
91
|
if (!(fields === null || fields === void 0 ? void 0 : fields.length) || !collection_name) {
|
|
90
92
|
throw new Error(__1.ERROR_REASONS.CREATE_COLLECTION_CHECK_PARAMS);
|
|
@@ -107,35 +109,29 @@ class Collection extends Database_1.Database {
|
|
|
107
109
|
// Get the consistency level value from the ConsistencyLevelEnum object.
|
|
108
110
|
const level = (_a = __1.ConsistencyLevelEnum[consistency_level]) !== null && _a !== void 0 ? _a : __1.ConsistencyLevelEnum.Bounded;
|
|
109
111
|
// Call the promisify function to create the collection.
|
|
110
|
-
const createPromise = yield (0, __1.promisify)(this.
|
|
112
|
+
const createPromise = yield (0, __1.promisify)(this.channelPool, 'CreateCollection', Object.assign(Object.assign({}, data), { schema: schemaBytes, consistency_level: level, enable_dynamic_field: data.enableDynamicField || data.enable_dynamic_field }), data.timeout || this.timeout);
|
|
111
113
|
// Return the promise.
|
|
112
114
|
return createPromise;
|
|
113
115
|
});
|
|
114
116
|
}
|
|
115
117
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* ```
|
|
134
|
-
* new milvusClient(MILUVS_ADDRESS).hasCollection({
|
|
135
|
-
* collection_name: 'my_collection',
|
|
136
|
-
* });
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
118
|
+
* Checks if a collection exists.
|
|
119
|
+
*
|
|
120
|
+
* @param {HasCollectionReq} data - The request parameters.
|
|
121
|
+
* @param {string} data.collection_name - The name of the collection to check.
|
|
122
|
+
* @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.
|
|
123
|
+
*
|
|
124
|
+
* @returns {Promise<BoolResponse>} The response from the server.
|
|
125
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
126
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
127
|
+
* @returns {boolean} value - `true` if the collection exists, `false` otherwise.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```
|
|
131
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
132
|
+
* const res = await milvusClient.hasCollection({ collection_name: 'my_collection' });
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
139
135
|
hasCollection(data) {
|
|
140
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
137
|
(0, __1.checkCollectionName)(data);
|
|
@@ -144,7 +140,7 @@ class Collection extends Database_1.Database {
|
|
|
144
140
|
value: true,
|
|
145
141
|
};
|
|
146
142
|
// avoid to call describe collection, because it has cache
|
|
147
|
-
const res = yield (0, __1.promisify)(this.
|
|
143
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'DescribeCollection', data, data.timeout || this.timeout);
|
|
148
144
|
if (res.status.error_code !== __1.ErrorCode.SUCCESS) {
|
|
149
145
|
response.value = false;
|
|
150
146
|
}
|
|
@@ -152,32 +148,27 @@ class Collection extends Database_1.Database {
|
|
|
152
148
|
});
|
|
153
149
|
}
|
|
154
150
|
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
* ```
|
|
175
|
-
* new milvusClient(MILUVS_ADDRESS).showCollections();
|
|
176
|
-
* ```
|
|
177
|
-
*/
|
|
151
|
+
* Lists all collections or gets the loading status of a collection.
|
|
152
|
+
*
|
|
153
|
+
* @param {ShowCollectionsReq} data - The request parameters.
|
|
154
|
+
* @param {ShowCollectionsType} [data.type] - The type of collections to show. Can be "All" (default) or "Loaded".
|
|
155
|
+
* @param {string[]} [data.collection_names] - If `type` is "Loaded", Milvus will return `collection_names` along with their in-memory percentages.
|
|
156
|
+
* @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.
|
|
157
|
+
*
|
|
158
|
+
* @returns {Promise<ShowCollectionsResponse>} The response from the server.
|
|
159
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
160
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
161
|
+
* @returns {CollectionData[]} data - An array containing information about each collection, including its name, ID, creation timestamp (UTC), and loaded percentage (100 means fully loaded).
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```
|
|
165
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
166
|
+
* const res = await milvusClient.showCollections();
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
178
169
|
showCollections(data) {
|
|
179
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const promise = yield (0, __1.promisify)(this.
|
|
171
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'ShowCollections', {
|
|
181
172
|
type: data ? data.type : __1.ShowCollectionsType.All,
|
|
182
173
|
collection_names: (data === null || data === void 0 ? void 0 : data.collection_names) || [],
|
|
183
174
|
}, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout);
|
|
@@ -195,32 +186,30 @@ class Collection extends Database_1.Database {
|
|
|
195
186
|
});
|
|
196
187
|
}
|
|
197
188
|
/**
|
|
198
|
-
*
|
|
189
|
+
* Modifies collection properties.
|
|
199
190
|
*
|
|
200
|
-
* @param data
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* | 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 |
|
|
191
|
+
* @param {AlterCollectionReq} data - The request parameters.
|
|
192
|
+
* @param {string} data.collection_name - The name of the collection to modify.
|
|
193
|
+
* @param {Object} data.properties - The properties to modify. For example, to change the TTL, use {"collection.ttl.seconds": 18000}.
|
|
194
|
+
* @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.
|
|
205
195
|
*
|
|
206
|
-
* @returns
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* | status | { error_code: number, reason: string } |
|
|
210
|
-
*
|
|
211
|
-
* #### Example
|
|
196
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
197
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
198
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
212
199
|
*
|
|
200
|
+
* @example
|
|
213
201
|
* ```
|
|
214
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
202
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
203
|
+
* const resStatus = await milvusClient.alterCollection({
|
|
215
204
|
* collection_name: 'my-collection',
|
|
216
205
|
* properties: {"collection.ttl.seconds": 18000}
|
|
217
|
-
*
|
|
206
|
+
* });
|
|
218
207
|
* ```
|
|
219
208
|
*/
|
|
220
209
|
alterCollection(data) {
|
|
221
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
222
211
|
(0, __1.checkCollectionName)(data);
|
|
223
|
-
const promise = yield (0, __1.promisify)(this.
|
|
212
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'AlterCollection', {
|
|
224
213
|
collection_name: data.collection_name,
|
|
225
214
|
properties: (0, __1.parseToKeyValue)(data.properties),
|
|
226
215
|
}, (data === null || data === void 0 ? void 0 : data.timeout) || this.timeout);
|
|
@@ -228,28 +217,22 @@ class Collection extends Database_1.Database {
|
|
|
228
217
|
});
|
|
229
218
|
}
|
|
230
219
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* @param data
|
|
234
|
-
* | Property | Type | Description |
|
|
235
|
-
* | :-- | :-- | :-- |
|
|
236
|
-
* | collection_name | String | Collection name |
|
|
237
|
-
* | 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 |
|
|
238
|
-
*
|
|
239
|
-
* @returns
|
|
240
|
-
* | Property | Description |
|
|
241
|
-
* | :-- | :-- |
|
|
242
|
-
* | status | { error_code: number, reason: string } |
|
|
243
|
-
* | schema | Information of all fields in this collection |
|
|
244
|
-
* | collectionID | Collection ID |
|
|
220
|
+
* Shows the details of a collection, such as its name and schema.
|
|
245
221
|
*
|
|
222
|
+
* @param {DescribeCollectionReq} data - The request parameters.
|
|
223
|
+
* @param {string} data.collection_name - The name of the collection to describe.
|
|
224
|
+
* @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.
|
|
246
225
|
*
|
|
247
|
-
*
|
|
226
|
+
* @returns {Promise<DescribeCollectionResponse>} The response from the server.
|
|
227
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
228
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
229
|
+
* @returns {FieldSchema[]} schema - Information of all fields in this collection.
|
|
230
|
+
* @returns {string} collectionID - The ID of the collection.
|
|
248
231
|
*
|
|
232
|
+
* @example
|
|
249
233
|
* ```
|
|
250
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
251
|
-
*
|
|
252
|
-
* });
|
|
234
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
235
|
+
* const res = await milvusClient.describeCollection({ collection_name: 'my_collection' });
|
|
253
236
|
* ```
|
|
254
237
|
*/
|
|
255
238
|
describeCollection(data) {
|
|
@@ -261,7 +244,7 @@ class Collection extends Database_1.Database {
|
|
|
261
244
|
return Promise.resolve(this.collectionInfoCache.get(key));
|
|
262
245
|
}
|
|
263
246
|
// get new data
|
|
264
|
-
const promise = yield (0, __1.promisify)(this.
|
|
247
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'DescribeCollection', data, data.timeout || this.timeout);
|
|
265
248
|
const results = (0, __1.formatDescribedCol)(promise);
|
|
266
249
|
// update cache
|
|
267
250
|
this.collectionInfoCache.set(key, results);
|
|
@@ -271,99 +254,81 @@ class Collection extends Database_1.Database {
|
|
|
271
254
|
/**
|
|
272
255
|
* Show the statistics information of a collection.
|
|
273
256
|
*
|
|
274
|
-
* @param data
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* | collection_name | String | Collection name |
|
|
278
|
-
* | 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 |
|
|
279
|
-
*
|
|
280
|
-
* @returns
|
|
281
|
-
* | Property | Description |
|
|
282
|
-
* | :-- | :-- |
|
|
283
|
-
* | status | { error_code: number, reason: string } |
|
|
284
|
-
* | stats | [{key: string, value: string}] |
|
|
285
|
-
* | data | Transform **stats** to { row_count: 0 } |
|
|
286
|
-
*
|
|
257
|
+
* @param {GetCollectionStatisticsReq} data - The request parameters.
|
|
258
|
+
* @param {string} data.collection_name - The name of the collection to get statistics for.
|
|
259
|
+
* @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.
|
|
287
260
|
*
|
|
288
|
-
*
|
|
261
|
+
* @returns {Promise<StatisticsResponse>} The response from the server.
|
|
262
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
263
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
264
|
+
* @returns {Object[]} stats - An array of objects, each containing a key-value pair representing a statistic.
|
|
265
|
+
* @returns {Object} data - Transforms **stats** to an object with properties representing statistics (e.g., { row_count: 0 }).
|
|
289
266
|
*
|
|
267
|
+
* @example
|
|
290
268
|
* ```
|
|
291
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
292
|
-
*
|
|
293
|
-
* });
|
|
269
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
270
|
+
* const res = await milvusClient.getCollectionStatistics({ collection_name: 'my_collection' });
|
|
294
271
|
* ```
|
|
295
272
|
*/
|
|
296
273
|
getCollectionStatistics(data) {
|
|
297
274
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
275
|
(0, __1.checkCollectionName)(data);
|
|
299
|
-
const promise = yield (0, __1.promisify)(this.
|
|
276
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'GetCollectionStatistics', data, data.timeout || this.timeout);
|
|
300
277
|
promise.data = (0, __1.formatKeyValueData)(promise.stats, ['row_count']);
|
|
301
278
|
return promise;
|
|
302
279
|
});
|
|
303
280
|
}
|
|
304
281
|
/**
|
|
305
282
|
* Load collection data into query nodes, then you can do vector search on this collection.
|
|
306
|
-
* It's async function, but
|
|
283
|
+
* It's an async function, but you can use showCollections to check loading status.
|
|
307
284
|
*
|
|
308
|
-
* @param data
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* | resource_groups? | String[] | resource group names |
|
|
314
|
-
* | 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 |
|
|
285
|
+
* @param {LoadCollectionReq} data - The request parameters.
|
|
286
|
+
* @param {string} data.collection_name - The name of the collection to load.
|
|
287
|
+
* @param {number} [data.replica_number] - The number of replicas.
|
|
288
|
+
* @param {string[]} [data.resource_groups] - The names of the resource groups.
|
|
289
|
+
* @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.
|
|
315
290
|
*
|
|
316
|
-
* @returns
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* | error_code | Error code number |
|
|
320
|
-
* | reason | Error cause |
|
|
321
|
-
*
|
|
322
|
-
* #### Example
|
|
291
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
292
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
293
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
323
294
|
*
|
|
295
|
+
* @example
|
|
324
296
|
* ```
|
|
325
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
326
|
-
*
|
|
327
|
-
* });
|
|
297
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
298
|
+
* const resStatus = await milvusClient.loadCollection({ collection_name: 'my_collection' });
|
|
328
299
|
* ```
|
|
329
300
|
*/
|
|
330
301
|
loadCollection(data) {
|
|
331
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
332
303
|
(0, __1.checkCollectionName)(data);
|
|
333
|
-
const promise = yield (0, __1.promisify)(this.
|
|
304
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'LoadCollection', data, data.timeout || this.timeout);
|
|
334
305
|
return promise;
|
|
335
306
|
});
|
|
336
307
|
}
|
|
337
308
|
/**
|
|
338
|
-
* Same function
|
|
339
|
-
*
|
|
309
|
+
* Same function as loadCollection, but it's a synchronous function.
|
|
310
|
+
* Helps to ensure this collection is loaded.
|
|
340
311
|
*
|
|
341
|
-
* @param data
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
* | resource_groups? | String[] | resource group |
|
|
347
|
-
* | 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 |
|
|
312
|
+
* @param {LoadCollectionReq} data - The request parameters.
|
|
313
|
+
* @param {string} data.collection_name - The name of the collection to load.
|
|
314
|
+
* @param {number} [data.replica_number] - The number of replicas.
|
|
315
|
+
* @param {string[]} [data.resource_groups] - The names of the resource groups.
|
|
316
|
+
* @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.
|
|
348
317
|
*
|
|
349
|
-
* @returns
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* | error_code | Error code number |
|
|
353
|
-
* | reason | Error cause |
|
|
354
|
-
*
|
|
355
|
-
* #### Example
|
|
318
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
319
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
320
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
356
321
|
*
|
|
322
|
+
* @example
|
|
357
323
|
* ```
|
|
358
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
359
|
-
*
|
|
360
|
-
* });
|
|
324
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
325
|
+
* const resStatus = await milvusClient.loadCollectionSync({ collection_name: 'my_collection' });
|
|
361
326
|
* ```
|
|
362
327
|
*/
|
|
363
328
|
loadCollectionSync(data) {
|
|
364
329
|
return __awaiter(this, void 0, void 0, function* () {
|
|
365
330
|
(0, __1.checkCollectionName)(data);
|
|
366
|
-
const promise = yield (0, __1.promisify)(this.
|
|
331
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'LoadCollection', data, data.timeout || this.timeout);
|
|
367
332
|
if (promise.error_code !== __1.ErrorCode.SUCCESS) {
|
|
368
333
|
throw new Error(`ErrorCode: ${promise.error_code}. Reason: ${promise.reason}`);
|
|
369
334
|
}
|
|
@@ -386,53 +351,43 @@ class Collection extends Database_1.Database {
|
|
|
386
351
|
* Release a collection from cache to reduce cache usage.
|
|
387
352
|
* Note that you cannot search while the corresponding collection is unloaded.
|
|
388
353
|
*
|
|
389
|
-
* @param data
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* | collection_name | String | Collection name |
|
|
393
|
-
* | 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 |
|
|
394
|
-
*
|
|
395
|
-
* @returns
|
|
396
|
-
* | Property | Description |
|
|
397
|
-
* | :-- | :-- |
|
|
398
|
-
* | error_code | Error code number |
|
|
399
|
-
* | reason | Error cause |
|
|
354
|
+
* @param {ReleaseLoadCollectionReq} data - The request parameters.
|
|
355
|
+
* @param {string} data.collection_name - The name of the collection to release.
|
|
356
|
+
* @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.
|
|
400
357
|
*
|
|
401
|
-
*
|
|
358
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
359
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
360
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
402
361
|
*
|
|
362
|
+
* @example
|
|
403
363
|
* ```
|
|
404
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
405
|
-
*
|
|
406
|
-
* });
|
|
364
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
365
|
+
* const resStatus = await milvusClient.releaseCollection({ collection_name: 'my_collection' });
|
|
407
366
|
* ```
|
|
408
367
|
*/
|
|
409
368
|
releaseCollection(data) {
|
|
410
369
|
return __awaiter(this, void 0, void 0, function* () {
|
|
411
370
|
(0, __1.checkCollectionName)(data);
|
|
412
|
-
const promise = yield (0, __1.promisify)(this.
|
|
371
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'ReleaseCollection', data, data.timeout || this.timeout);
|
|
413
372
|
return promise;
|
|
414
373
|
});
|
|
415
374
|
}
|
|
416
375
|
/**
|
|
417
|
-
* Rename a collection
|
|
418
|
-
*
|
|
419
|
-
* @param data
|
|
420
|
-
* | Property | Type | Description |
|
|
421
|
-
* | :-- | :-- | :-- |
|
|
422
|
-
* | collection_name | String | old collection name |
|
|
423
|
-
* | new_collection_name | String | new collection name |
|
|
424
|
-
* | 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 |
|
|
376
|
+
* Rename a collection.
|
|
425
377
|
*
|
|
426
|
-
* @
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
* | reason | Error cause |
|
|
378
|
+
* @param {RenameCollectionReq} data - The request parameters.
|
|
379
|
+
* @param {string} data.collection_name - The current name of the collection.
|
|
380
|
+
* @param {string} data.new_collection_name - The new name for the collection.
|
|
381
|
+
* @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.
|
|
431
382
|
*
|
|
432
|
-
*
|
|
383
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
384
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
385
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
433
386
|
*
|
|
387
|
+
* @example
|
|
434
388
|
* ```
|
|
435
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
389
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
390
|
+
* const resStatus = await milvusClient.renameCollection({
|
|
436
391
|
* collection_name: 'my_collection',
|
|
437
392
|
* new_collection_name: 'my_new_collection'
|
|
438
393
|
* });
|
|
@@ -440,7 +395,7 @@ class Collection extends Database_1.Database {
|
|
|
440
395
|
*/
|
|
441
396
|
renameCollection(data) {
|
|
442
397
|
return __awaiter(this, void 0, void 0, function* () {
|
|
443
|
-
const promise = yield (0, __1.promisify)(this.
|
|
398
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'RenameCollection', {
|
|
444
399
|
oldName: data.collection_name,
|
|
445
400
|
newName: data.new_collection_name,
|
|
446
401
|
}, data.timeout || this.timeout);
|
|
@@ -450,92 +405,139 @@ class Collection extends Database_1.Database {
|
|
|
450
405
|
/**
|
|
451
406
|
* Drop a collection. Note that this drops all data in the collection.
|
|
452
407
|
*
|
|
453
|
-
* @param data
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* | collection_name | String | Collection name |
|
|
457
|
-
* | 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. |
|
|
408
|
+
* @param {DropCollectionReq} data - The request parameters.
|
|
409
|
+
* @param {string} data.collection_name - The name of the collection to drop.
|
|
410
|
+
* @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.
|
|
458
411
|
*
|
|
459
|
-
* @returns
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* | error_code | Error code number |
|
|
463
|
-
* | reason | Error cause |
|
|
464
|
-
*
|
|
465
|
-
* #### Example
|
|
412
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
413
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
414
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
466
415
|
*
|
|
416
|
+
* @example
|
|
467
417
|
* ```
|
|
468
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
469
|
-
*
|
|
470
|
-
* });
|
|
418
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
419
|
+
* const resStatus = await milvusClient.dropCollection({ collection_name: 'my_collection' });
|
|
471
420
|
* ```
|
|
472
421
|
*/
|
|
473
422
|
dropCollection(data) {
|
|
474
423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
475
424
|
(0, __1.checkCollectionName)(data);
|
|
476
|
-
const promise = yield (0, __1.promisify)(this.
|
|
425
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'DropCollection', data, data.timeout || this.timeout);
|
|
477
426
|
this.collectionInfoCache.delete(`${this.metadata.get(__1.METADATA.DATABASE)}:${data.collection_name}`);
|
|
478
427
|
return promise;
|
|
479
428
|
});
|
|
480
429
|
}
|
|
481
430
|
/**
|
|
482
|
-
* Create collection alias, then you can use alias instead of collection_name when you
|
|
431
|
+
* Create a collection alias, then you can use the alias instead of the collection_name when you perform a vector search.
|
|
483
432
|
*
|
|
484
|
-
* @param data
|
|
485
|
-
*
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
* | collection_name | String | Collection name |
|
|
489
|
-
* | 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. |
|
|
433
|
+
* @param {CreateAliasReq} data - The request parameters.
|
|
434
|
+
* @param {string} data.alias - The alias name.
|
|
435
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
436
|
+
* @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.
|
|
490
437
|
*
|
|
491
|
-
* @returns
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
* | error_code | Error code number |
|
|
495
|
-
* | reason | Error cause |
|
|
438
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
439
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
440
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
496
441
|
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```
|
|
444
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
445
|
+
* const resStatus = await milvusClient.createAlias({
|
|
446
|
+
* alias: 'my_collection_alias',
|
|
447
|
+
* collection_name: 'my_collection',
|
|
448
|
+
* });
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
createAlias(data) {
|
|
452
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
453
|
+
(0, __1.checkCollectionName)(data);
|
|
454
|
+
if (!data.alias) {
|
|
455
|
+
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
456
|
+
}
|
|
457
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'CreateAlias', data, data.timeout || this.timeout);
|
|
458
|
+
return promise;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Describe a collection alias.
|
|
463
|
+
*
|
|
464
|
+
* @param {DescribeAliasReq} data - The request parameters.
|
|
465
|
+
* @param {string} data.alias - The alias name.
|
|
466
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
467
|
+
* @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.
|
|
497
468
|
*
|
|
498
|
-
*
|
|
469
|
+
* @returns {Promise<DescribeAliasResponse>} The response from the server.
|
|
470
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
471
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
472
|
+
* @returns {string} collection - The name of the collection that the alias points to.
|
|
473
|
+
* @returns {string} alias - The alias of the collection.
|
|
499
474
|
*
|
|
475
|
+
* @example
|
|
500
476
|
* ```
|
|
501
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
502
|
-
*
|
|
477
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
478
|
+
* const res = await milvusClient.describeAlias({
|
|
479
|
+
* alias: 'my_collection_alias',
|
|
503
480
|
* collection_name: 'my_collection',
|
|
504
481
|
* });
|
|
505
482
|
* ```
|
|
506
483
|
*/
|
|
507
|
-
|
|
484
|
+
describeAlias(data) {
|
|
508
485
|
return __awaiter(this, void 0, void 0, function* () {
|
|
509
486
|
(0, __1.checkCollectionName)(data);
|
|
510
487
|
if (!data.alias) {
|
|
511
488
|
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
512
489
|
}
|
|
513
|
-
const promise = yield (0, __1.promisify)(this.
|
|
490
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'DescribeAlias', data, data.timeout || this.timeout);
|
|
514
491
|
return promise;
|
|
515
492
|
});
|
|
516
493
|
}
|
|
517
494
|
/**
|
|
518
|
-
*
|
|
495
|
+
* List all aliases of a collection.
|
|
519
496
|
*
|
|
520
|
-
* @param data
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* | alias | String | alias name |
|
|
524
|
-
* | collection_name | String | Collection name |
|
|
525
|
-
* | 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. |
|
|
497
|
+
* @param {ListAliasesReq} data - The request parameters.
|
|
498
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
499
|
+
* @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.
|
|
526
500
|
*
|
|
527
|
-
* @returns
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
501
|
+
* @returns {Promise<ListAliasesResponse>} The response from the server.
|
|
502
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
503
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
504
|
+
* @returns {string[]} aliases - The list of aliases of the collection.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```
|
|
508
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
509
|
+
* const res = await milvusClient.listAliases({
|
|
510
|
+
* collection_name: 'my_collection',
|
|
511
|
+
* });
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
listAliases(data) {
|
|
515
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
516
|
+
(0, __1.checkCollectionName)(data);
|
|
517
|
+
if (!data.collection_name) {
|
|
518
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
519
|
+
}
|
|
520
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'ListAliases', data, data.timeout || this.timeout);
|
|
521
|
+
return promise;
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Drop a collection alias.
|
|
532
526
|
*
|
|
527
|
+
* @param {DropAliasReq} data - The request parameters.
|
|
528
|
+
* @param {string} data.alias - The alias name.
|
|
529
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
530
|
+
* @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.
|
|
533
531
|
*
|
|
534
|
-
*
|
|
532
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
533
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
534
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
535
535
|
*
|
|
536
|
+
* @example
|
|
536
537
|
* ```
|
|
537
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
538
|
-
*
|
|
538
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
539
|
+
* const resStatus = await milvusClient.dropAlias({
|
|
540
|
+
* alias: 'my_collection_alias',
|
|
539
541
|
* collection_name: 'my_collection',
|
|
540
542
|
* });
|
|
541
543
|
* ```
|
|
@@ -545,32 +547,27 @@ class Collection extends Database_1.Database {
|
|
|
545
547
|
if (!data.alias) {
|
|
546
548
|
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
547
549
|
}
|
|
548
|
-
const promise = yield (0, __1.promisify)(this.
|
|
550
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'DropAlias', data, data.timeout || this.timeout);
|
|
549
551
|
return promise;
|
|
550
552
|
});
|
|
551
553
|
}
|
|
552
554
|
/**
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
* @param data
|
|
556
|
-
* | Property | Type | Description |
|
|
557
|
-
* | :-- | :-- | :-- |
|
|
558
|
-
* | alias | String | alias name |
|
|
559
|
-
* | collection_name | String | Collection name |
|
|
560
|
-
* | 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. |
|
|
555
|
+
* Alter a collection alias.
|
|
561
556
|
*
|
|
562
|
-
* @
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
* | reason | Error cause |
|
|
557
|
+
* @param {AlterAliasReq} data - The request parameters.
|
|
558
|
+
* @param {string} data.alias - The alias name.
|
|
559
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
560
|
+
* @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.
|
|
567
561
|
*
|
|
562
|
+
* @returns {Promise<ResStatus>} The response status of the operation.
|
|
563
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
564
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
568
565
|
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
566
|
+
* @example
|
|
571
567
|
* ```
|
|
572
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
573
|
-
*
|
|
568
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
569
|
+
* const resStatus = await milvusClient.alterAlias({
|
|
570
|
+
* alias: 'my_collection_alias',
|
|
574
571
|
* collection_name: 'my_collection',
|
|
575
572
|
* });
|
|
576
573
|
* ```
|
|
@@ -581,29 +578,26 @@ class Collection extends Database_1.Database {
|
|
|
581
578
|
if (!data.alias) {
|
|
582
579
|
throw new Error(__1.ERROR_REASONS.ALIAS_NAME_IS_REQUIRED);
|
|
583
580
|
}
|
|
584
|
-
const promise = yield (0, __1.promisify)(this.
|
|
581
|
+
const promise = yield (0, __1.promisify)(this.channelPool, 'AlterAlias', data, data.timeout || this.timeout);
|
|
585
582
|
return promise;
|
|
586
583
|
});
|
|
587
584
|
}
|
|
588
585
|
/**
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
* @param data
|
|
592
|
-
* | Property | Type | Description |
|
|
593
|
-
* | :-- | :-- | :-- |
|
|
594
|
-
* | collection_name | String | The collection name to compact |
|
|
595
|
-
* | 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 |
|
|
586
|
+
* Perform compaction on a collection. This operation reduces the storage space used by the collection by removing deleted data and optimizing the data layout.
|
|
596
587
|
*
|
|
597
|
-
* @
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
* | status | { error_code: number, reason: string } |
|
|
601
|
-
* | compactionID | compaction ID |
|
|
588
|
+
* @param {CompactReq} data - The request parameters.
|
|
589
|
+
* @param {string} data.collection_name - The name of the collection to compact.
|
|
590
|
+
* @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.
|
|
602
591
|
*
|
|
603
|
-
*
|
|
592
|
+
* @returns {Promise<CompactionResponse>} The response of the operation.
|
|
593
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
594
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
595
|
+
* @returns {string} compactionID - The ID of the compaction operation.
|
|
604
596
|
*
|
|
597
|
+
* @example
|
|
605
598
|
* ```
|
|
606
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
599
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
600
|
+
* const resStatus = await milvusClient.compact({
|
|
607
601
|
* collection_name: 'my_collection',
|
|
608
602
|
* });
|
|
609
603
|
* ```
|
|
@@ -612,32 +606,29 @@ class Collection extends Database_1.Database {
|
|
|
612
606
|
return __awaiter(this, void 0, void 0, function* () {
|
|
613
607
|
(0, __1.checkCollectionName)(data);
|
|
614
608
|
const collectionInfo = yield this.describeCollection(data);
|
|
615
|
-
const res = yield (0, __1.promisify)(this.
|
|
609
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'ManualCompaction', {
|
|
616
610
|
collectionID: collectionInfo.collectionID,
|
|
617
611
|
}, data.timeout || this.timeout);
|
|
618
612
|
return res;
|
|
619
613
|
});
|
|
620
614
|
}
|
|
621
615
|
/**
|
|
622
|
-
* Get compaction
|
|
616
|
+
* Get the compaction state of a targeted compaction id.
|
|
623
617
|
*
|
|
624
|
-
* @param data
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
* | compactionID | number or string | the id returned by compact |
|
|
628
|
-
* | 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 |
|
|
618
|
+
* @param {GetCompactionStateReq} data - The request parameters.
|
|
619
|
+
* @param {number|string} data.compactionID - The ID of the compaction operation, returned by the compact method.
|
|
620
|
+
* @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.
|
|
629
621
|
*
|
|
630
|
-
* @returns
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
* | state | the state of the compaction |
|
|
635
|
-
*
|
|
636
|
-
* #### Example
|
|
622
|
+
* @returns {Promise<GetCompactionStateResponse>} The response of the operation.
|
|
623
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
624
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
625
|
+
* @returns {string} state - The state of the compaction operation.
|
|
637
626
|
*
|
|
627
|
+
* @example
|
|
638
628
|
* ```
|
|
639
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
640
|
-
*
|
|
629
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
630
|
+
* const resStatus = await milvusClient.getCompactionState({
|
|
631
|
+
* compactionID: 'your_compaction_id',
|
|
641
632
|
* });
|
|
642
633
|
* ```
|
|
643
634
|
*/
|
|
@@ -646,30 +637,27 @@ class Collection extends Database_1.Database {
|
|
|
646
637
|
if (!data || !data.compactionID) {
|
|
647
638
|
throw new Error(__1.ERROR_REASONS.COMPACTION_ID_IS_REQUIRED);
|
|
648
639
|
}
|
|
649
|
-
const res = yield (0, __1.promisify)(this.
|
|
640
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'GetCompactionState', data, data.timeout || this.timeout);
|
|
650
641
|
return res;
|
|
651
642
|
});
|
|
652
643
|
}
|
|
653
644
|
/**
|
|
654
|
-
* Get compaction states of a targeted compaction id
|
|
655
|
-
*
|
|
656
|
-
* @param data
|
|
657
|
-
* | Property | Type | Description |
|
|
658
|
-
* | :-- | :-- | :-- |
|
|
659
|
-
* | compactionID | number or string | the id returned by compact |
|
|
660
|
-
* | 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 |
|
|
645
|
+
* Get the compaction states of a targeted compaction id.
|
|
661
646
|
*
|
|
662
|
-
* @
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
* | status | { error_code: number, reason: string } |
|
|
666
|
-
* | state | the state of the compaction |
|
|
647
|
+
* @param {GetCompactionPlansReq} data - The request parameters.
|
|
648
|
+
* @param {number|string} data.compactionID - The ID of the compaction operation, returned by the compact method.
|
|
649
|
+
* @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.
|
|
667
650
|
*
|
|
668
|
-
*
|
|
651
|
+
* @returns {Promise<GetCompactionPlansResponse>} The response of the operation.
|
|
652
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
653
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
654
|
+
* @returns {string} state - The state of the compaction operation.
|
|
669
655
|
*
|
|
656
|
+
* @example
|
|
670
657
|
* ```
|
|
671
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
672
|
-
*
|
|
658
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
659
|
+
* const resStatus = await milvusClient.getCompactionStateWithPlans({
|
|
660
|
+
* compactionID: 'your_compaction_id',
|
|
673
661
|
* });
|
|
674
662
|
* ```
|
|
675
663
|
*/
|
|
@@ -678,35 +666,31 @@ class Collection extends Database_1.Database {
|
|
|
678
666
|
if (!data || !data.compactionID) {
|
|
679
667
|
throw new Error(__1.ERROR_REASONS.COMPACTION_ID_IS_REQUIRED);
|
|
680
668
|
}
|
|
681
|
-
const res = yield (0, __1.promisify)(this.
|
|
669
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'GetCompactionStateWithPlans', data, data.timeout || this.timeout);
|
|
682
670
|
return res;
|
|
683
671
|
});
|
|
684
672
|
}
|
|
685
673
|
/**
|
|
686
|
-
* Get replicas
|
|
687
|
-
*
|
|
688
|
-
* @param data
|
|
689
|
-
* | Property | Type | Description |
|
|
690
|
-
* | :-- | :-- | :-- |
|
|
691
|
-
* | collectionID | number or string | the id returned by compact |
|
|
692
|
-
* | 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 |
|
|
674
|
+
* Get replicas of a collection.
|
|
693
675
|
*
|
|
694
|
-
* @
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
* | status | { error_code: number, reason: string } |
|
|
698
|
-
* | ReplicaInfo[] | replica info array |
|
|
676
|
+
* @param {GetReplicaReq} data - The request parameters.
|
|
677
|
+
* @param {number|string} data.collectionID - The ID of the collection, returned by the compact method.
|
|
678
|
+
* @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.
|
|
699
679
|
*
|
|
700
|
-
*
|
|
680
|
+
* @returns {Promise<ReplicasResponse>} The response of the operation.
|
|
681
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
682
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
683
|
+
* @returns {ReplicaInfo[]} replicas - An array of replica information.
|
|
701
684
|
*
|
|
685
|
+
* @example
|
|
702
686
|
* ```
|
|
703
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
704
|
-
*
|
|
687
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
688
|
+
* const resStatus = await milvusClient.getReplicas({
|
|
689
|
+
* collectionID: 'your_collection_id',
|
|
705
690
|
* });
|
|
706
|
-
*
|
|
707
691
|
* ```
|
|
708
692
|
*
|
|
709
|
-
*
|
|
693
|
+
* @returns
|
|
710
694
|
* ```
|
|
711
695
|
* {
|
|
712
696
|
* replicas: [
|
|
@@ -727,32 +711,29 @@ class Collection extends Database_1.Database {
|
|
|
727
711
|
if (!data || !data.collectionID) {
|
|
728
712
|
throw new Error(__1.ERROR_REASONS.COLLECTION_ID_IS_REQUIRED);
|
|
729
713
|
}
|
|
730
|
-
const res = yield (0, __1.promisify)(this.
|
|
714
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'GetReplicas', data, data.timeout || this.timeout);
|
|
731
715
|
return res;
|
|
732
716
|
});
|
|
733
717
|
}
|
|
734
718
|
/**
|
|
735
|
-
* Get loading progress of a collection
|
|
736
|
-
*
|
|
737
|
-
* @param data
|
|
738
|
-
* | Property | Type | Description |
|
|
739
|
-
* | :-- | :-- | :-- |
|
|
740
|
-
* | collection_name | string | the name of the collection |
|
|
741
|
-
* | 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 |
|
|
719
|
+
* Get the loading progress of a collection.
|
|
742
720
|
*
|
|
743
|
-
* @
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
* | status | { error_code: number, reason: string } |
|
|
747
|
-
* | total_row_num | the total number of rows in the collection |
|
|
748
|
-
* | total_loaded_row_num | the total number of loaded rows in the collection |
|
|
721
|
+
* @param {GetLoadingProgressReq} data - The request parameters.
|
|
722
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
723
|
+
* @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.
|
|
749
724
|
*
|
|
750
|
-
* @
|
|
725
|
+
* @returns {Promise<GetLoadingProgressResponse>} The response of the operation.
|
|
726
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
727
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
728
|
+
* @returns {number} total_row_num - The total number of rows in the collection.
|
|
729
|
+
* @returns {number} total_loaded_row_num - The total number of loaded rows in the collection.
|
|
751
730
|
*
|
|
752
|
-
*
|
|
731
|
+
* @throws {Error} if `collection_name` property is not present in `data`.
|
|
753
732
|
*
|
|
733
|
+
* @example
|
|
754
734
|
* ```
|
|
755
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
735
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
736
|
+
* const resStatus = await milvusClient.getLoadingProgress({
|
|
756
737
|
* collection_name: 'my_collection',
|
|
757
738
|
* });
|
|
758
739
|
* ```
|
|
@@ -762,31 +743,28 @@ class Collection extends Database_1.Database {
|
|
|
762
743
|
if (!data || !data.collection_name) {
|
|
763
744
|
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
764
745
|
}
|
|
765
|
-
const res = yield (0, __1.promisify)(this.
|
|
746
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'GetLoadingProgress', data, data.timeout || this.timeout);
|
|
766
747
|
return res;
|
|
767
748
|
});
|
|
768
749
|
}
|
|
769
750
|
/**
|
|
770
|
-
* Get the loading state of a collection
|
|
751
|
+
* Get the loading state of a collection.
|
|
771
752
|
*
|
|
772
|
-
* @param data
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
* | collection_name | string | the name of the collection |
|
|
776
|
-
* | 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 |
|
|
753
|
+
* @param {GetLoadStateReq} data - The request parameters.
|
|
754
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
755
|
+
* @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.
|
|
777
756
|
*
|
|
778
|
-
* @returns
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
* | state | the loading state of the collection |
|
|
783
|
-
*
|
|
784
|
-
* @throws {Error} if `collection_name` property is not present in `data`
|
|
757
|
+
* @returns {Promise<GetLoadStateResponse>} The response of the operation.
|
|
758
|
+
* @returns {string} status.error_code - The error code of the operation.
|
|
759
|
+
* @returns {string} status.reason - The reason for the error, if any.
|
|
760
|
+
* @returns {string} state - The loading state of the collection.
|
|
785
761
|
*
|
|
786
|
-
*
|
|
762
|
+
* @throws {Error} if `collection_name` property is not present in `data`.
|
|
787
763
|
*
|
|
764
|
+
* @example
|
|
788
765
|
* ```
|
|
789
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
766
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
767
|
+
* const resStatus = await milvusClient.getLoadState({
|
|
790
768
|
* collection_name: 'my_collection',
|
|
791
769
|
* });
|
|
792
770
|
* ```
|
|
@@ -796,30 +774,25 @@ class Collection extends Database_1.Database {
|
|
|
796
774
|
if (!data || !data.collection_name) {
|
|
797
775
|
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
798
776
|
}
|
|
799
|
-
const res = yield (0, __1.promisify)(this.
|
|
777
|
+
const res = yield (0, __1.promisify)(this.channelPool, 'GetLoadState', data, data.timeout || this.timeout);
|
|
800
778
|
return res;
|
|
801
779
|
});
|
|
802
780
|
}
|
|
803
781
|
/**
|
|
804
|
-
* Get the primary key field name
|
|
805
|
-
*
|
|
806
|
-
* @param data
|
|
807
|
-
* | Property | Type | Description |
|
|
808
|
-
* | :-- | :-- | :-- |
|
|
809
|
-
* | collection_name | string | the name of the collection |
|
|
810
|
-
* | 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 |
|
|
782
|
+
* Get the primary key field name of a collection.
|
|
811
783
|
*
|
|
812
|
-
* @
|
|
813
|
-
*
|
|
814
|
-
*
|
|
815
|
-
* | pkfield | the primary key field name |
|
|
784
|
+
* @param {DescribeCollectionReq} data - The request parameters.
|
|
785
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
786
|
+
* @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.
|
|
816
787
|
*
|
|
817
|
-
* @
|
|
788
|
+
* @returns {Promise<string>} The primary key field name of the collection.
|
|
818
789
|
*
|
|
819
|
-
*
|
|
790
|
+
* @throws {Error} if `collection_name` property is not present in `data`.
|
|
820
791
|
*
|
|
792
|
+
* @example
|
|
821
793
|
* ```
|
|
822
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
794
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
795
|
+
* const pkFieldName = await milvusClient.getPkFieldName({
|
|
823
796
|
* collection_name: 'my_collection',
|
|
824
797
|
* });
|
|
825
798
|
* ```
|
|
@@ -843,25 +816,20 @@ class Collection extends Database_1.Database {
|
|
|
843
816
|
});
|
|
844
817
|
}
|
|
845
818
|
/**
|
|
846
|
-
* Get the primary key field type
|
|
847
|
-
*
|
|
848
|
-
* @param data
|
|
849
|
-
* | Property | Type | Description |
|
|
850
|
-
* | :-- | :-- | :-- |
|
|
851
|
-
* | collection_name | string | the name of the collection |
|
|
852
|
-
* | 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 |
|
|
819
|
+
* Get the primary key field type.
|
|
853
820
|
*
|
|
854
|
-
* @
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* | pkFieldType | the primary key field type |
|
|
821
|
+
* @param {DescribeCollectionReq} data - The request parameters.
|
|
822
|
+
* @param {string} data.collection_name - The name of the collection.
|
|
823
|
+
* @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.
|
|
858
824
|
*
|
|
859
|
-
* @
|
|
825
|
+
* @returns {Promise<keyof typeof DataType>} The primary key field type.
|
|
860
826
|
*
|
|
861
|
-
*
|
|
827
|
+
* @throws {Error} if `collection_name` property is not present in `data`.
|
|
862
828
|
*
|
|
829
|
+
* @example
|
|
863
830
|
* ```
|
|
864
|
-
* new milvusClient(MILUVS_ADDRESS)
|
|
831
|
+
* const milvusClient = new milvusClient(MILUVS_ADDRESS);
|
|
832
|
+
* const pkFieldType = await milvusClient.getPkFieldType({
|
|
865
833
|
* collection_name: 'my_collection',
|
|
866
834
|
* });
|
|
867
835
|
* ```
|