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