@zilliz/milvus2-sdk-node 2.2.10 → 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 +3 -3
- package/dist/milvus/MilvusClient.d.ts +0 -4
- package/dist/milvus/MilvusClient.js +20 -48
- 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 +4 -1
- package/dist/milvus/const/index.js +4 -1
- package/dist/milvus/const/index.js.map +1 -1
- 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/grpc/BaseClient.d.ts +16 -7
- package/dist/milvus/grpc/BaseClient.js +37 -18
- package/dist/milvus/grpc/BaseClient.js.map +1 -1
- package/dist/milvus/grpc/Collection.d.ts +32 -3
- package/dist/milvus/grpc/Collection.js +242 -416
- package/dist/milvus/grpc/Collection.js.map +1 -1
- package/dist/milvus/grpc/Data.d.ts +68 -8
- package/dist/milvus/grpc/Data.js +539 -566
- package/dist/milvus/grpc/Data.js.map +1 -1
- 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 +18 -8
- package/dist/milvus/grpc/GrpcClient.js +87 -156
- package/dist/milvus/grpc/GrpcClient.js.map +1 -1
- package/dist/milvus/grpc/MilvusIndex.d.ts +1 -1
- package/dist/milvus/grpc/MilvusIndex.js +46 -142
- package/dist/milvus/grpc/MilvusIndex.js.map +1 -1
- package/dist/milvus/grpc/Partition.d.ts +1 -1
- package/dist/milvus/grpc/Partition.js +53 -157
- package/dist/milvus/grpc/Partition.js.map +1 -1
- package/dist/milvus/grpc/Resource.d.ts +2 -2
- package/dist/milvus/grpc/Resource.js +64 -170
- package/dist/milvus/grpc/Resource.js.map +1 -1
- package/dist/milvus/grpc/User.d.ts +1 -1
- package/dist/milvus/grpc/User.js +193 -381
- package/dist/milvus/grpc/User.js.map +1 -1
- package/dist/milvus/index.d.ts +1 -1
- package/dist/milvus/index.js +1 -1
- 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/{types.js → orm/index.js} +3 -11
- 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/Data.d.ts +41 -5
- package/dist/milvus/types/Database.d.ts +12 -0
- package/dist/milvus/types/Database.js +3 -0
- 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/MilvusIndex.d.ts +1 -1
- package/dist/milvus/types/Resource.d.ts +1 -1
- package/dist/milvus/types/{Index.d.ts → index.d.ts} +2 -0
- package/dist/milvus/types/{Index.js → index.js} +3 -1
- 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 +13 -10
- 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 -125
- package/dist/utils/Validate.js.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/test.d.ts +0 -29
- package/dist/utils/test.js +0 -112
- package/dist/utils/test.js.map +0 -1
- /package/dist/{utils → milvus/utils}/Blob.d.ts +0 -0
package/dist/milvus/grpc/Data.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,54 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
9
|
});
|
|
36
10
|
};
|
|
37
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
-
function step(op) {
|
|
42
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
-
switch (op[0]) {
|
|
47
|
-
case 0: case 1: t = op; break;
|
|
48
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
-
default:
|
|
52
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
-
if (t[2]) _.ops.pop();
|
|
57
|
-
_.trys.pop(); continue;
|
|
58
|
-
}
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
65
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
66
|
-
if (ar || !(i in from)) {
|
|
67
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
68
|
-
ar[i] = from[i];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
72
|
-
};
|
|
73
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
12
|
exports.Data = void 0;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
function Data() {
|
|
81
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
13
|
+
const __1 = require("../");
|
|
14
|
+
const Collection_1 = require("./Collection");
|
|
15
|
+
class Data extends Collection_1.Collection {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
82
18
|
// vectorTypes
|
|
83
|
-
|
|
84
|
-
return _this;
|
|
19
|
+
this.vectorTypes = [__1.DataType.BinaryVector, __1.DataType.FloatVector];
|
|
85
20
|
}
|
|
86
21
|
/**
|
|
87
22
|
* Insert data into Milvus.
|
|
@@ -91,8 +26,7 @@ var Data = /** @class */ (function (_super) {
|
|
|
91
26
|
* | :--- | :-- | :-- |
|
|
92
27
|
* | collection_name | String | Collection name |
|
|
93
28
|
* | partition_name(optional)| String | Partition name |
|
|
94
|
-
* | fields_data | { [x: string]: any }[] | If the field type is binary, the vector data length needs to be dimension / 8 |
|
|
95
|
-
* | hash_keys(optional) | Number[] | The hash value depends on the primarykey value |
|
|
29
|
+
* | fields_data or data | { [x: string]: any }[] | If the field type is binary, the vector data length needs to be dimension / 8 |
|
|
96
30
|
* | 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 |
|
|
97
31
|
|
|
98
32
|
*
|
|
@@ -117,132 +51,150 @@ var Data = /** @class */ (function (_super) {
|
|
|
117
51
|
* });
|
|
118
52
|
* ```
|
|
119
53
|
*/
|
|
120
|
-
|
|
121
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
54
|
+
insert(data) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
(0, __1.checkCollectionName)(data);
|
|
57
|
+
// ensure fields data available
|
|
58
|
+
data.fields_data = data.fields_data || data.data;
|
|
59
|
+
if (!data.fields_data ||
|
|
60
|
+
!Array.isArray(data.fields_data) ||
|
|
61
|
+
!data.fields_data.length) {
|
|
62
|
+
throw new Error(__1.ERROR_REASONS.INSERT_CHECK_FIELD_DATA_IS_REQUIRED);
|
|
63
|
+
}
|
|
64
|
+
const { collection_name } = data;
|
|
65
|
+
const collectionInfo = yield this.describeCollection({
|
|
66
|
+
collection_name,
|
|
67
|
+
});
|
|
68
|
+
if (collectionInfo.status.error_code !== __1.ErrorCode.SUCCESS) {
|
|
69
|
+
throw new Error(collectionInfo.status.reason);
|
|
70
|
+
}
|
|
71
|
+
// Tip: The field data sequence needs to be set same as `collectionInfo.schema.fields`.
|
|
72
|
+
// If primarykey is set `autoid = true`, you cannot insert the data.
|
|
73
|
+
const fieldsDataMap = new Map(collectionInfo.schema.fields
|
|
74
|
+
.filter(v => !v.is_primary_key || !v.autoID)
|
|
75
|
+
.map(v => [
|
|
76
|
+
v.name,
|
|
77
|
+
{
|
|
78
|
+
name: v.name,
|
|
79
|
+
type: v.data_type,
|
|
80
|
+
dim: Number((0, __1.findKeyValue)(v.type_params, 'dim')),
|
|
81
|
+
value: [], // value container
|
|
82
|
+
},
|
|
83
|
+
]));
|
|
84
|
+
// The actual data we pass to Milvus gRPC.
|
|
85
|
+
const params = Object.assign(Object.assign({}, data), { num_rows: data.fields_data.length });
|
|
86
|
+
// dynamic field is enabled, create $meta field
|
|
87
|
+
const isDynamic = collectionInfo.schema.enable_dynamic_field;
|
|
88
|
+
if (isDynamic) {
|
|
89
|
+
fieldsDataMap.set(__1.DEFAULT_DYNAMIC_FIELD, {
|
|
90
|
+
name: __1.DEFAULT_DYNAMIC_FIELD,
|
|
91
|
+
type: 'JSON',
|
|
92
|
+
value: [], // value container
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
// Loop through each row and set the corresponding field values in the Map.
|
|
96
|
+
data.fields_data.forEach((v, i) => {
|
|
97
|
+
// if support dynamic field, all field not in the schema would be grouped to a dynamic field
|
|
98
|
+
v = isDynamic
|
|
99
|
+
? (0, __1.generateDynamicRow)(v, fieldsDataMap, __1.DEFAULT_DYNAMIC_FIELD)
|
|
100
|
+
: v;
|
|
101
|
+
// get each fieldname in the data object
|
|
102
|
+
const fieldNames = Object.keys(v);
|
|
103
|
+
// go through each fieldname and encode or format data
|
|
104
|
+
fieldNames.forEach(name => {
|
|
105
|
+
const target = fieldsDataMap.get(name);
|
|
106
|
+
if (!target) {
|
|
107
|
+
throw new Error(`${__1.ERROR_REASONS.INSERT_CHECK_WRONG_FIELD} ${i}`);
|
|
108
|
+
}
|
|
109
|
+
if (__1.DataTypeMap[target.type] === __1.DataType.BinaryVector &&
|
|
110
|
+
v[name].length !== target.dim / 8) {
|
|
111
|
+
throw new Error(__1.ERROR_REASONS.INSERT_CHECK_WRONG_DIM);
|
|
112
|
+
}
|
|
113
|
+
// encode data
|
|
114
|
+
switch (__1.DataTypeMap[target.type]) {
|
|
115
|
+
case __1.DataType.BinaryVector:
|
|
116
|
+
case __1.DataType.FloatVector:
|
|
117
|
+
for (let val of v[name]) {
|
|
118
|
+
target.value.push(val);
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
case __1.DataType.JSON:
|
|
122
|
+
// ensure empty string
|
|
123
|
+
target.value[i] = Buffer.from(JSON.stringify(v[name] || {}));
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
target.value[i] = v[name];
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
// transform data from map to array, milvus grpc params
|
|
132
|
+
params.fields_data = Array.from(fieldsDataMap.values()).map(v => {
|
|
133
|
+
// milvus return string for field type, so we define the DataTypeMap to the value we need.
|
|
134
|
+
// but if milvus change the string, may cause we cant find value.
|
|
135
|
+
const type = __1.DataTypeMap[v.type];
|
|
136
|
+
const key = this.vectorTypes.includes(type) ? 'vectors' : 'scalars';
|
|
137
|
+
let dataKey = 'float_vector';
|
|
138
|
+
switch (type) {
|
|
139
|
+
case __1.DataType.FloatVector:
|
|
140
|
+
dataKey = 'float_vector';
|
|
141
|
+
break;
|
|
142
|
+
case __1.DataType.BinaryVector:
|
|
143
|
+
dataKey = 'binary_vector';
|
|
144
|
+
break;
|
|
145
|
+
case __1.DataType.Double:
|
|
146
|
+
dataKey = 'double_data';
|
|
147
|
+
break;
|
|
148
|
+
case __1.DataType.Float:
|
|
149
|
+
dataKey = 'float_data';
|
|
150
|
+
break;
|
|
151
|
+
case __1.DataType.Int64:
|
|
152
|
+
dataKey = 'long_data';
|
|
153
|
+
break;
|
|
154
|
+
case __1.DataType.Int32:
|
|
155
|
+
case __1.DataType.Int16:
|
|
156
|
+
case __1.DataType.Int8:
|
|
157
|
+
dataKey = 'int_data';
|
|
158
|
+
break;
|
|
159
|
+
case __1.DataType.Bool:
|
|
160
|
+
dataKey = 'bool_data';
|
|
161
|
+
break;
|
|
162
|
+
case __1.DataType.VarChar:
|
|
163
|
+
dataKey = 'string_data';
|
|
164
|
+
break;
|
|
165
|
+
case __1.DataType.JSON:
|
|
166
|
+
dataKey = 'json_data';
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
throw new Error(`${__1.ERROR_REASONS.INSERT_CHECK_WRONG_DATA_TYPE} "${v.type}."`);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
type,
|
|
173
|
+
field_name: v.name,
|
|
174
|
+
is_dynamic: v.name === __1.DEFAULT_DYNAMIC_FIELD,
|
|
175
|
+
[key]: type === __1.DataType.FloatVector
|
|
176
|
+
? {
|
|
177
|
+
dim: v.dim,
|
|
178
|
+
[dataKey]: {
|
|
179
|
+
data: v.value,
|
|
151
180
|
},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
fieldNames.forEach(function (name) {
|
|
158
|
-
var target = fieldsData.get(name);
|
|
159
|
-
if (!target) {
|
|
160
|
-
throw new Error("".concat(__1.ERROR_REASONS.INSERT_CHECK_WRONG_FIELD, " ").concat(i));
|
|
161
|
-
}
|
|
162
|
-
var isVector = _this.vectorTypes.includes(__1.DataTypeMap[target.type.toLowerCase()]);
|
|
163
|
-
if (__1.DataTypeMap[target.type.toLowerCase()] === __1.DataType.BinaryVector &&
|
|
164
|
-
v[name].length !== target.dim / 8) {
|
|
165
|
-
throw new Error(__1.ERROR_REASONS.INSERT_CHECK_WRONG_DIM);
|
|
166
|
-
}
|
|
167
|
-
if (isVector) {
|
|
168
|
-
for (var _i = 0, _a = v[name]; _i < _a.length; _i++) {
|
|
169
|
-
var val = _a[_i];
|
|
170
|
-
target.value.push(val);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
target.value[i] = v[name];
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
params.fields_data = Array.from(fieldsData.values()).map(function (v) {
|
|
179
|
-
var _a, _b, _c, _d;
|
|
180
|
-
// milvus return string for field type, so we define the DataTypeMap to the value we need.
|
|
181
|
-
// but if milvus change the string, may casue we cant find value.
|
|
182
|
-
var type = __1.DataTypeMap[v.type.toLowerCase()];
|
|
183
|
-
var key = _this.vectorTypes.includes(type) ? 'vectors' : 'scalars';
|
|
184
|
-
var dataKey = 'float_vector';
|
|
185
|
-
switch (type) {
|
|
186
|
-
case __1.DataType.FloatVector:
|
|
187
|
-
dataKey = 'float_vector';
|
|
188
|
-
break;
|
|
189
|
-
case __1.DataType.BinaryVector:
|
|
190
|
-
dataKey = 'binary_vector';
|
|
191
|
-
break;
|
|
192
|
-
case __1.DataType.Double:
|
|
193
|
-
dataKey = 'double_data';
|
|
194
|
-
break;
|
|
195
|
-
case __1.DataType.Float:
|
|
196
|
-
dataKey = 'float_data';
|
|
197
|
-
break;
|
|
198
|
-
case __1.DataType.Int64:
|
|
199
|
-
dataKey = 'long_data';
|
|
200
|
-
break;
|
|
201
|
-
case __1.DataType.Int32:
|
|
202
|
-
case __1.DataType.Int16:
|
|
203
|
-
case __1.DataType.Int8:
|
|
204
|
-
dataKey = 'int_data';
|
|
205
|
-
break;
|
|
206
|
-
case __1.DataType.Bool:
|
|
207
|
-
dataKey = 'bool_data';
|
|
208
|
-
break;
|
|
209
|
-
case __1.DataType.VarChar:
|
|
210
|
-
dataKey = 'string_data';
|
|
211
|
-
break;
|
|
212
|
-
default:
|
|
213
|
-
throw new Error("".concat(__1.ERROR_REASONS.INSERT_CHECK_WRONG_DATA_TYPE, " \"").concat(v.type, ".\""));
|
|
181
|
+
}
|
|
182
|
+
: type === __1.DataType.BinaryVector
|
|
183
|
+
? {
|
|
184
|
+
dim: v.dim,
|
|
185
|
+
[dataKey]: (0, __1.parseBinaryVectorToBytes)(v.value),
|
|
214
186
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
187
|
+
: {
|
|
188
|
+
[dataKey]: {
|
|
189
|
+
data: v.value,
|
|
218
190
|
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
dim: v.dim
|
|
222
|
-
},
|
|
223
|
-
_b[dataKey] = {
|
|
224
|
-
data: v.value,
|
|
225
|
-
},
|
|
226
|
-
_b) : type === __1.DataType.BinaryVector
|
|
227
|
-
? (_c = {
|
|
228
|
-
dim: v.dim
|
|
229
|
-
},
|
|
230
|
-
_c[dataKey] = (0, utils_1.parseBinaryVectorToBytes)(v.value),
|
|
231
|
-
_c) : (_d = {},
|
|
232
|
-
_d[dataKey] = {
|
|
233
|
-
data: v.value,
|
|
234
|
-
},
|
|
235
|
-
_d),
|
|
236
|
-
_a;
|
|
237
|
-
});
|
|
238
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'Insert', params, data.timeout || this.timeout)];
|
|
239
|
-
case 2:
|
|
240
|
-
promise = _a.sent();
|
|
241
|
-
return [2 /*return*/, promise];
|
|
242
|
-
}
|
|
191
|
+
},
|
|
192
|
+
};
|
|
243
193
|
});
|
|
194
|
+
const promise = yield (0, __1.promisify)(this.client, 'Insert', params, data.timeout || this.timeout);
|
|
195
|
+
return promise;
|
|
244
196
|
});
|
|
245
|
-
}
|
|
197
|
+
}
|
|
246
198
|
/**
|
|
247
199
|
* Delete entities in Milvus
|
|
248
200
|
*
|
|
@@ -251,7 +203,7 @@ var Data = /** @class */ (function (_super) {
|
|
|
251
203
|
* | :--- | :-- | :-- |
|
|
252
204
|
* | collection_name | String | Collection name |
|
|
253
205
|
* | partition_name(optional)| String | Partition name |
|
|
254
|
-
* | expr | String | Boolean expression used to filter attribute. |
|
|
206
|
+
* | expr or filter | String | Boolean expression used to filter attribute. |
|
|
255
207
|
* | 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 |
|
|
256
208
|
|
|
257
209
|
*
|
|
@@ -271,23 +223,62 @@ var Data = /** @class */ (function (_super) {
|
|
|
271
223
|
* });
|
|
272
224
|
* ```
|
|
273
225
|
*/
|
|
274
|
-
|
|
275
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
226
|
+
deleteEntities(data) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
if (!data || !data.collection_name) {
|
|
229
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
230
|
+
}
|
|
231
|
+
// check expr or filter
|
|
232
|
+
if (!data.filter && !data.expr) {
|
|
233
|
+
throw new Error(__1.ERROR_REASONS.FILTER_EXPR_REQUIRED);
|
|
234
|
+
}
|
|
235
|
+
// filter > expr
|
|
236
|
+
data.expr = data.filter || data.expr;
|
|
237
|
+
const promise = yield (0, __1.promisify)(this.client, 'Delete', data, data.timeout || this.timeout);
|
|
238
|
+
return promise;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Delete entities in Milvus
|
|
243
|
+
*
|
|
244
|
+
* @param data
|
|
245
|
+
* | Property | Type | Description |
|
|
246
|
+
* | :--- | :-- | :-- |
|
|
247
|
+
* | collection_name | String | Collection name |
|
|
248
|
+
* | partition_name(optional)| String | Partition name |
|
|
249
|
+
* | ids | String[] or Number[] | ids to delete |
|
|
250
|
+
* | 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 |
|
|
251
|
+
|
|
252
|
+
*
|
|
253
|
+
* @returns
|
|
254
|
+
* | Property | Description |
|
|
255
|
+
* | :-- | :-- |
|
|
256
|
+
* | status | { error_code: number, reason: string } |
|
|
257
|
+
* | IDs | ID array of the successfully deleted data |
|
|
258
|
+
*
|
|
259
|
+
*
|
|
260
|
+
* #### Example
|
|
261
|
+
*
|
|
262
|
+
* ```
|
|
263
|
+
* new milvusClient(MILUVS_ADDRESS).deleteEntities({
|
|
264
|
+
* collection_name: COLLECTION_NAME,
|
|
265
|
+
* expr: 'id in [1,2,3,4]'
|
|
266
|
+
* });
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
delete(data) {
|
|
270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
+
if (!data || !data.collection_name) {
|
|
272
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
273
|
+
}
|
|
274
|
+
if (!data.ids || data.ids.length === 0) {
|
|
275
|
+
throw new Error(__1.ERROR_REASONS.IDS_REQUIRED);
|
|
276
|
+
}
|
|
277
|
+
const pkField = yield this.getPkFieldName(data);
|
|
278
|
+
const req = Object.assign(Object.assign({}, data), { expr: `${pkField} in [${data.ids.join(',')}]` });
|
|
279
|
+
return this.deleteEntities(req);
|
|
289
280
|
});
|
|
290
|
-
}
|
|
281
|
+
}
|
|
291
282
|
/**
|
|
292
283
|
* Perform vector similarity search.
|
|
293
284
|
*
|
|
@@ -295,7 +286,7 @@ var Data = /** @class */ (function (_super) {
|
|
|
295
286
|
* | Property | Type | Description |
|
|
296
287
|
* | :--- | :-- | :-- |
|
|
297
288
|
* | collection_name | String | Collection name |
|
|
298
|
-
* | vectors or vector | Number[][] or Number[] | Original vector to search with |
|
|
289
|
+
* | vectors or data or (vector) | Number[][] or Number[] | Original vector to search with |
|
|
299
290
|
* | partition_names(optional)| String[] | Array of partition names |
|
|
300
291
|
* | limit(optional) | number | topk alias |
|
|
301
292
|
* | topk(optional) | number | topk |
|
|
@@ -321,137 +312,158 @@ var Data = /** @class */ (function (_super) {
|
|
|
321
312
|
* });
|
|
322
313
|
* ```
|
|
323
314
|
*/
|
|
324
|
-
|
|
315
|
+
search(data) {
|
|
325
316
|
var _a, _b, _c, _d;
|
|
326
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
dim = type === __1.DataType.BinaryVector ? dim / 8 : dim;
|
|
353
|
-
// anns field
|
|
354
|
-
anns_field = f.name;
|
|
355
|
-
// vector type
|
|
356
|
-
vectorType_1 = type;
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
// save field name
|
|
360
|
-
defaultOutputFields.push(f.name);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
search_params = data.search_params || {
|
|
364
|
-
anns_field: anns_field,
|
|
365
|
-
topk: data.limit ||
|
|
366
|
-
data.topk ||
|
|
367
|
-
__1.DEFAULT_TOPK,
|
|
368
|
-
offset: data.offset || 0,
|
|
369
|
-
metric_type: data.metric_type || __1.DEFAULT_METRIC_TYPE,
|
|
370
|
-
params: JSON.stringify(data.params || {}),
|
|
371
|
-
};
|
|
372
|
-
searchVectors = data.vectors || [
|
|
373
|
-
data.vector,
|
|
374
|
-
];
|
|
375
|
-
round_decimal_1 = (_b = (_a = data.search_params) === null || _a === void 0 ? void 0 : _a.round_decimal) !== null && _b !== void 0 ? _b : (_c = data.params) === null || _c === void 0 ? void 0 : _c.round_decimal;
|
|
376
|
-
PlaceholderGroup = this.milvusProto.lookupType('milvus.proto.common.PlaceholderGroup');
|
|
377
|
-
placeholderGroupBytes = PlaceholderGroup.encode(PlaceholderGroup.create({
|
|
378
|
-
placeholders: [
|
|
379
|
-
{
|
|
380
|
-
tag: '$0',
|
|
381
|
-
type: vectorType_1,
|
|
382
|
-
values: searchVectors.map(function (v) {
|
|
383
|
-
return vectorType_1 === __1.DataType.BinaryVector
|
|
384
|
-
? (0, utils_1.parseBinaryVectorToBytes)(v)
|
|
385
|
-
: (0, utils_1.parseFloatVectorToBytes)(v);
|
|
386
|
-
}),
|
|
387
|
-
},
|
|
388
|
-
],
|
|
389
|
-
})).finish();
|
|
390
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'Search', {
|
|
391
|
-
collection_name: data.collection_name,
|
|
392
|
-
partition_names: data.partition_names,
|
|
393
|
-
output_fields: data.output_fields || defaultOutputFields,
|
|
394
|
-
nq: data.nq || searchVectors.length,
|
|
395
|
-
dsl: data.expr || data.filter || '',
|
|
396
|
-
dsl_type: __1.DslType.BoolExprV1,
|
|
397
|
-
placeholder_group: placeholderGroupBytes,
|
|
398
|
-
search_params: (0, utils_1.parseToKeyValue)(search_params),
|
|
399
|
-
}, data.timeout || this.timeout)];
|
|
400
|
-
case 3:
|
|
401
|
-
promise = _f.sent();
|
|
402
|
-
results_1 = [];
|
|
403
|
-
if (promise.results) {
|
|
404
|
-
_e = promise.results, topks = _e.topks, scores_1 = _e.scores, fields_data = _e.fields_data, ids = _e.ids;
|
|
405
|
-
fieldsData_1 = fields_data.map(function (item, i) {
|
|
406
|
-
// if search result is empty, will cause value is undefined.
|
|
407
|
-
var value = item.field ? item[item.field] : undefined;
|
|
408
|
-
return {
|
|
409
|
-
type: item.type,
|
|
410
|
-
field_name: item.field_name,
|
|
411
|
-
data: value ? value[value === null || value === void 0 ? void 0 : value.data].data : '',
|
|
412
|
-
};
|
|
413
|
-
});
|
|
414
|
-
idData_1 = ids ? (_d = ids[ids.id_field]) === null || _d === void 0 ? void 0 : _d.data : undefined;
|
|
415
|
-
/**
|
|
416
|
-
* This code block formats the search results returned by Milvus into row data for easier use.
|
|
417
|
-
* Milvus supports multiple queries to search and returns all columns data, so we need to splice the data for each search result using the `topk` variable.
|
|
418
|
-
* The `topk` variable is the key we use to splice data for every search result.
|
|
419
|
-
* The `scores` array is spliced using the `topk` value, and the resulting scores are formatted to the specified precision using the `formatNumberPrecision` function. The resulting row data is then pushed to the `results` array.
|
|
420
|
-
*/
|
|
421
|
-
topks.forEach(function (v, index) {
|
|
422
|
-
var topk = Number(v);
|
|
423
|
-
scores_1.splice(0, topk).forEach(function (score, scoreIndex) {
|
|
424
|
-
var i = index === 0 ? scoreIndex : scoreIndex + topk;
|
|
425
|
-
var fixedScore = typeof round_decimal_1 === 'undefined' || round_decimal_1 === -1
|
|
426
|
-
? score
|
|
427
|
-
: (0, utils_1.formatNumberPrecision)(score, round_decimal_1);
|
|
428
|
-
var result = {
|
|
429
|
-
score: fixedScore,
|
|
430
|
-
id: idData_1 ? idData_1[i] : '',
|
|
431
|
-
};
|
|
432
|
-
fieldsData_1.forEach(function (field) {
|
|
433
|
-
result[field.field_name] = field.data[i];
|
|
434
|
-
});
|
|
435
|
-
results_1.push(result);
|
|
436
|
-
});
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
return [2 /*return*/, {
|
|
440
|
-
status: promise.status,
|
|
441
|
-
results: results_1,
|
|
442
|
-
}];
|
|
443
|
-
case 4:
|
|
444
|
-
err_1 = _f.sent();
|
|
445
|
-
/* istanbul ignore next */
|
|
446
|
-
throw new Error(err_1);
|
|
447
|
-
case 5: return [2 /*return*/];
|
|
317
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
// params check
|
|
319
|
+
(0, __1.checkSearchParams)(data);
|
|
320
|
+
try {
|
|
321
|
+
// get collection info
|
|
322
|
+
const collectionInfo = yield this.describeCollection({
|
|
323
|
+
collection_name: data.collection_name,
|
|
324
|
+
});
|
|
325
|
+
// get information from collection info
|
|
326
|
+
let vectorType;
|
|
327
|
+
let defaultOutputFields = [];
|
|
328
|
+
let anns_field;
|
|
329
|
+
for (let i = 0; i < collectionInfo.schema.fields.length; i++) {
|
|
330
|
+
const f = collectionInfo.schema.fields[i];
|
|
331
|
+
const type = __1.DataTypeMap[f.data_type];
|
|
332
|
+
// filter vector field
|
|
333
|
+
if (type === __1.DataType.FloatVector || type === __1.DataType.BinaryVector) {
|
|
334
|
+
// anns field
|
|
335
|
+
anns_field = f.name;
|
|
336
|
+
// vector type
|
|
337
|
+
vectorType = type;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
// save field name
|
|
341
|
+
defaultOutputFields.push(f.name);
|
|
342
|
+
}
|
|
448
343
|
}
|
|
449
|
-
|
|
344
|
+
// create search params
|
|
345
|
+
const search_params = data.search_params || {
|
|
346
|
+
anns_field: anns_field,
|
|
347
|
+
topk: data.limit ||
|
|
348
|
+
data.topk ||
|
|
349
|
+
__1.DEFAULT_TOPK,
|
|
350
|
+
offset: data.offset || 0,
|
|
351
|
+
metric_type: data.metric_type || __1.DEFAULT_METRIC_TYPE,
|
|
352
|
+
params: JSON.stringify(data.params || {}),
|
|
353
|
+
};
|
|
354
|
+
// create search vectors
|
|
355
|
+
let searchVectors = data.vectors ||
|
|
356
|
+
data.data ||
|
|
357
|
+
data.vector;
|
|
358
|
+
// make sure the searchVectors format is correct
|
|
359
|
+
if (!Array.isArray(searchVectors[0])) {
|
|
360
|
+
searchVectors = [searchVectors];
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* It will decide the score precision.
|
|
364
|
+
* If round_decimal is 3, need return like 3.142
|
|
365
|
+
* And if Milvus return like 3.142, Node will add more number after this like 3.142000047683716.
|
|
366
|
+
* So the score need to slice by round_decimal
|
|
367
|
+
*/
|
|
368
|
+
const round_decimal = (_b = (_a = data.search_params) === null || _a === void 0 ? void 0 : _a.round_decimal) !== null && _b !== void 0 ? _b : (_c = data.params) === null || _c === void 0 ? void 0 : _c.round_decimal;
|
|
369
|
+
// create placeholder_group
|
|
370
|
+
const PlaceholderGroup = this.milvusProto.lookupType('milvus.proto.common.PlaceholderGroup');
|
|
371
|
+
// tag $0 is hard code in milvus, when dsltype is expr
|
|
372
|
+
const placeholderGroupBytes = PlaceholderGroup.encode(PlaceholderGroup.create({
|
|
373
|
+
placeholders: [
|
|
374
|
+
{
|
|
375
|
+
tag: '$0',
|
|
376
|
+
type: vectorType,
|
|
377
|
+
values: searchVectors.map(v => vectorType === __1.DataType.BinaryVector
|
|
378
|
+
? (0, __1.parseBinaryVectorToBytes)(v)
|
|
379
|
+
: (0, __1.parseFloatVectorToBytes)(v)),
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
})).finish();
|
|
383
|
+
const promise = yield (0, __1.promisify)(this.client, 'Search', {
|
|
384
|
+
collection_name: data.collection_name,
|
|
385
|
+
partition_names: data.partition_names,
|
|
386
|
+
output_fields: data.output_fields || defaultOutputFields,
|
|
387
|
+
nq: data.nq || searchVectors.length,
|
|
388
|
+
dsl: data.expr || data.filter || '',
|
|
389
|
+
dsl_type: __1.DslType.BoolExprV1,
|
|
390
|
+
placeholder_group: placeholderGroupBytes,
|
|
391
|
+
search_params: (0, __1.parseToKeyValue)(search_params),
|
|
392
|
+
consistency_level: data.consistency_level,
|
|
393
|
+
}, data.timeout || this.timeout);
|
|
394
|
+
// if search failed, return empty with status
|
|
395
|
+
if (promise.status.error_code !== __1.ErrorCode.SUCCESS) {
|
|
396
|
+
return {
|
|
397
|
+
status: promise.status,
|
|
398
|
+
results: [],
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
// build final results array
|
|
402
|
+
const results = [];
|
|
403
|
+
const { topks, scores, fields_data, ids } = promise.results;
|
|
404
|
+
// build fields data map
|
|
405
|
+
const fieldsDataMap = (0, __1.getFieldDataMap)(fields_data);
|
|
406
|
+
// build output name array
|
|
407
|
+
const output_fields = [
|
|
408
|
+
'id',
|
|
409
|
+
...(promise.results.output_fields ||
|
|
410
|
+
fields_data.map(f => f.field_name)),
|
|
411
|
+
];
|
|
412
|
+
// vector id support int / str id.
|
|
413
|
+
const idData = ids ? (_d = ids[ids.id_field]) === null || _d === void 0 ? void 0 : _d.data : undefined;
|
|
414
|
+
// add id column
|
|
415
|
+
fieldsDataMap.set('id', idData);
|
|
416
|
+
// fieldsDataMap.set('score', scores); TODO: fieldDataMap to support formatter
|
|
417
|
+
/**
|
|
418
|
+
* This code block formats the search results returned by Milvus into row data for easier use.
|
|
419
|
+
* Milvus supports multiple queries to search and returns all columns data, so we need to splice the data for each search result using the `topk` variable.
|
|
420
|
+
* The `topk` variable is the key we use to splice data for every search result.
|
|
421
|
+
* The `scores` array is spliced using the `topk` value, and the resulting scores are formatted to the specified precision using the `formatNumberPrecision` function. The resulting row data is then pushed to the `results` array.
|
|
422
|
+
*/
|
|
423
|
+
topks.forEach((v, index) => {
|
|
424
|
+
const topk = Number(v);
|
|
425
|
+
scores.splice(0, topk).forEach((score, scoreIndex) => {
|
|
426
|
+
// get correct index
|
|
427
|
+
const i = index === 0 ? scoreIndex : scoreIndex + topk;
|
|
428
|
+
// fix round_decimal
|
|
429
|
+
const fixedScore = typeof round_decimal === 'undefined' || round_decimal === -1
|
|
430
|
+
? score
|
|
431
|
+
: (0, __1.formatNumberPrecision)(score, round_decimal);
|
|
432
|
+
// init result object
|
|
433
|
+
const result = { score: fixedScore };
|
|
434
|
+
// build result,
|
|
435
|
+
output_fields.forEach(field_name => {
|
|
436
|
+
// Check if the field_name exists in the fieldsDataMap
|
|
437
|
+
const isFixedSchema = fieldsDataMap.has(field_name);
|
|
438
|
+
// Get the data for the field_name from the fieldsDataMap
|
|
439
|
+
// If the field_name is not in the fieldsDataMap, use the DEFAULT_DYNAMIC_FIELD
|
|
440
|
+
const data = fieldsDataMap.get(isFixedSchema ? field_name : __1.DEFAULT_DYNAMIC_FIELD);
|
|
441
|
+
// make data[i] safe
|
|
442
|
+
data[i] = data[i] || {};
|
|
443
|
+
// extract dynamic info from dynamic field if necessary
|
|
444
|
+
result[field_name] = isFixedSchema ? data[i] : data[i][field_name];
|
|
445
|
+
});
|
|
446
|
+
// init result slot
|
|
447
|
+
results[index] = results[index] || [];
|
|
448
|
+
// push result data
|
|
449
|
+
results[index].push(result);
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
return {
|
|
453
|
+
status: promise.status,
|
|
454
|
+
// if only searching 1 vector, return the first object of results array
|
|
455
|
+
results: searchVectors.length === 1 ? results[0] : results,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
catch (err) {
|
|
459
|
+
/* istanbul ignore next */
|
|
460
|
+
throw new Error(err);
|
|
461
|
+
}
|
|
450
462
|
});
|
|
451
|
-
}
|
|
463
|
+
}
|
|
452
464
|
/**
|
|
453
465
|
* Milvus temporarily buffers the newly inserted vectors in the cache. Call `flush()` to persist them to the object storage.
|
|
454
|
-
* It's async function, so it's will take some times to
|
|
466
|
+
* It's async function, so it's will take some times to execute.
|
|
455
467
|
* @param data
|
|
456
468
|
* | Property | Type | Description |
|
|
457
469
|
* | :--- | :-- | :-- |
|
|
@@ -472,25 +484,17 @@ var Data = /** @class */ (function (_super) {
|
|
|
472
484
|
* });
|
|
473
485
|
* ```
|
|
474
486
|
*/
|
|
475
|
-
|
|
476
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
485
|
-
}
|
|
486
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'Flush', data, data.timeout || this.timeout)];
|
|
487
|
-
case 1:
|
|
488
|
-
res = _a.sent();
|
|
489
|
-
return [2 /*return*/, res];
|
|
490
|
-
}
|
|
491
|
-
});
|
|
487
|
+
flush(data) {
|
|
488
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
489
|
+
if (!data ||
|
|
490
|
+
!Array.isArray(data.collection_names) ||
|
|
491
|
+
!data.collection_names.length) {
|
|
492
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
493
|
+
}
|
|
494
|
+
const res = yield (0, __1.promisify)(this.client, 'Flush', data, data.timeout || this.timeout);
|
|
495
|
+
return res;
|
|
492
496
|
});
|
|
493
|
-
}
|
|
497
|
+
}
|
|
494
498
|
/**
|
|
495
499
|
* It's same function as flush. But flushSync is sync function.
|
|
496
500
|
* So you can ensure it's flushed after function return the result.
|
|
@@ -515,43 +519,30 @@ var Data = /** @class */ (function (_super) {
|
|
|
515
519
|
* });
|
|
516
520
|
* ```
|
|
517
521
|
*/
|
|
518
|
-
|
|
519
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
return [4 /*yield*/, this.getFlushState({ segmentIDs: segIDs })];
|
|
541
|
-
case 3:
|
|
542
|
-
flushRes = _a.sent();
|
|
543
|
-
return [4 /*yield*/, (0, utils_1.sleep)(100)];
|
|
544
|
-
case 4:
|
|
545
|
-
_a.sent();
|
|
546
|
-
isFlushed = flushRes.flushed;
|
|
547
|
-
return [3 /*break*/, 2];
|
|
548
|
-
case 5:
|
|
549
|
-
// Before Milvus pre-GA will throw error
|
|
550
|
-
return [2 /*return*/, flushRes];
|
|
551
|
-
}
|
|
552
|
-
});
|
|
522
|
+
flushSync(data) {
|
|
523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
524
|
+
if (!data ||
|
|
525
|
+
!Array.isArray(data.collection_names) ||
|
|
526
|
+
!data.collection_names.length) {
|
|
527
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
528
|
+
}
|
|
529
|
+
// copy flushed collection names
|
|
530
|
+
const res = yield (0, __1.promisify)(this.client, 'Flush', data, data.timeout || this.timeout);
|
|
531
|
+
// After flush will return collection segment ids, need use GetPersistentSegmentInfo to check segment flush status.
|
|
532
|
+
const segIDs = Object.keys(res.coll_segIDs)
|
|
533
|
+
.map(v => res.coll_segIDs[v].data)
|
|
534
|
+
.reduce((pre, cur) => [...pre, ...cur], []);
|
|
535
|
+
let isFlushed = false;
|
|
536
|
+
let flushRes = null;
|
|
537
|
+
while (!isFlushed) {
|
|
538
|
+
flushRes = yield this.getFlushState({ segmentIDs: segIDs });
|
|
539
|
+
yield (0, __1.sleep)(100);
|
|
540
|
+
isFlushed = flushRes.flushed;
|
|
541
|
+
}
|
|
542
|
+
// Before Milvus pre-GA will throw error
|
|
543
|
+
return flushRes;
|
|
553
544
|
});
|
|
554
|
-
}
|
|
545
|
+
}
|
|
555
546
|
/**
|
|
556
547
|
* Query vector data in Milvus. Current release of Milvus only supports expression as fieldname in [id1,id2,id3]
|
|
557
548
|
*
|
|
@@ -559,7 +550,7 @@ var Data = /** @class */ (function (_super) {
|
|
|
559
550
|
* | Property | Type | Description |
|
|
560
551
|
* | :--- | :-- | :-- |
|
|
561
552
|
* | collection_name | String | Collection name |
|
|
562
|
-
* | expr | String | Scalar field filter expression |
|
|
553
|
+
* | expr or filter | String | Scalar field filter expression |
|
|
563
554
|
* | partitions_names(optional) | String[] | Array of partition names |
|
|
564
555
|
* | output_fields | String[] | Vector or scalar field to be returned |
|
|
565
556
|
* | 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 |
|
|
@@ -583,77 +574,108 @@ var Data = /** @class */ (function (_super) {
|
|
|
583
574
|
* });
|
|
584
575
|
* ```
|
|
585
576
|
*/
|
|
586
|
-
|
|
587
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
var _a, _b;
|
|
639
|
-
if (!results[i]) {
|
|
640
|
-
results[i] = (_a = {},
|
|
641
|
-
_a[v.field_name] = d,
|
|
642
|
-
_a);
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
results[i] = __assign(__assign({}, results[i]), (_b = {}, _b[v.field_name] = d, _b));
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
return [2 /*return*/, {
|
|
650
|
-
status: promise.status,
|
|
651
|
-
data: results,
|
|
652
|
-
}];
|
|
653
|
-
}
|
|
577
|
+
query(data) {
|
|
578
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
579
|
+
(0, __1.checkCollectionName)(data);
|
|
580
|
+
// Set up limits and offset for the query
|
|
581
|
+
let limits;
|
|
582
|
+
let offset;
|
|
583
|
+
if (typeof data.limit === 'number') {
|
|
584
|
+
limits = { limit: data.limit };
|
|
585
|
+
}
|
|
586
|
+
if (typeof data.offset === 'number') {
|
|
587
|
+
offset = { offset: data.offset };
|
|
588
|
+
}
|
|
589
|
+
// check expr or filter
|
|
590
|
+
if (!data.filter && !data.expr) {
|
|
591
|
+
throw new Error(__1.ERROR_REASONS.FILTER_EXPR_REQUIRED);
|
|
592
|
+
}
|
|
593
|
+
// filter > expr
|
|
594
|
+
data.expr = data.filter || data.expr;
|
|
595
|
+
// Execute the query and get the results
|
|
596
|
+
const promise = yield (0, __1.promisify)(this.client, 'Query', Object.assign(Object.assign({}, data), { query_params: (0, __1.parseToKeyValue)(Object.assign(Object.assign({}, limits), offset)) }), data.timeout || this.timeout);
|
|
597
|
+
// compatible with milvus before v2.2.9
|
|
598
|
+
const output_fields = promise.output_fields || promise.fields_data.map(f => f.field_name);
|
|
599
|
+
// Initialize an array to hold the query results
|
|
600
|
+
const results = [];
|
|
601
|
+
const fieldsDataMap = (0, __1.getFieldDataMap)(promise.fields_data);
|
|
602
|
+
// For each output field, check if it has a fixed schema or not
|
|
603
|
+
const fieldData = output_fields.map(field_name => {
|
|
604
|
+
// Check if the field_name exists in the fieldsDataMap
|
|
605
|
+
const isFixedSchema = fieldsDataMap.has(field_name);
|
|
606
|
+
// Get the data for the field_name from the fieldsDataMap
|
|
607
|
+
// If the field_name is not in the fieldsDataMap, use the DEFAULT_DYNAMIC_FIELD
|
|
608
|
+
const data = fieldsDataMap.get(isFixedSchema ? field_name : __1.DEFAULT_DYNAMIC_FIELD);
|
|
609
|
+
// Return an object containing the field_name and its corresponding data
|
|
610
|
+
// If the schema is fixed, use the data directly
|
|
611
|
+
// If the schema is not fixed, map the data to extract the field_name values
|
|
612
|
+
return {
|
|
613
|
+
data: isFixedSchema ? data : data.map((d) => d[field_name]),
|
|
614
|
+
field_name,
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
// parse column data to [{fieldname:value}]
|
|
618
|
+
fieldData.forEach((v) => {
|
|
619
|
+
v.data.forEach((d, i) => {
|
|
620
|
+
if (!results[i]) {
|
|
621
|
+
results[i] = {
|
|
622
|
+
[v.field_name]: d,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
else {
|
|
626
|
+
results[i] = Object.assign(Object.assign({}, results[i]), { [v.field_name]: d });
|
|
627
|
+
}
|
|
628
|
+
});
|
|
654
629
|
});
|
|
630
|
+
return {
|
|
631
|
+
status: promise.status,
|
|
632
|
+
data: results,
|
|
633
|
+
};
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* get vector data by providing ids in Milvus
|
|
638
|
+
*
|
|
639
|
+
* @param data
|
|
640
|
+
* | Property | Type | Description |
|
|
641
|
+
* | :--- | :-- | :-- |
|
|
642
|
+
* | collection_name | String | Collection name |
|
|
643
|
+
* | ids | String[] | ids to get |
|
|
644
|
+
* | partitions_names(optional) | String[] | Array of partition names |
|
|
645
|
+
* | output_fields | String[] | Vector or scalar field to be returned |
|
|
646
|
+
* | 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 |
|
|
647
|
+
|
|
648
|
+
* | params | {key: value}[] | An optional key pair json array
|
|
649
|
+
*
|
|
650
|
+
* @returns
|
|
651
|
+
* | Property | Description |
|
|
652
|
+
* | :-- | :-- |
|
|
653
|
+
* | status | { error_code: number,reason:string } |
|
|
654
|
+
* | data | Data of all fields that you defined in `output_fields`, {field_name: value}[] |
|
|
655
|
+
*
|
|
656
|
+
*
|
|
657
|
+
* #### Example
|
|
658
|
+
*
|
|
659
|
+
* ```
|
|
660
|
+
* new milvusClient(MILUVS_ADDRESS).get({
|
|
661
|
+
* collection_name: 'my_collection',
|
|
662
|
+
* ids: [1,2,3,4,5,6,7,8],
|
|
663
|
+
* output_fields: ["age"],
|
|
664
|
+
* });
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
667
|
+
get(data) {
|
|
668
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
669
|
+
(0, __1.checkCollectionName)(data);
|
|
670
|
+
const pkField = yield this.getPkFieldName(data);
|
|
671
|
+
if (!data.ids || data.ids.length === 0) {
|
|
672
|
+
throw new Error(__1.ERROR_REASONS.IDS_REQUIRED);
|
|
673
|
+
}
|
|
674
|
+
// build query req
|
|
675
|
+
const req = Object.assign(Object.assign({}, data), { expr: `${pkField} in [${data.ids.join(',')}]` });
|
|
676
|
+
return this.query(req);
|
|
655
677
|
});
|
|
656
|
-
}
|
|
678
|
+
}
|
|
657
679
|
/**
|
|
658
680
|
* @ignore
|
|
659
681
|
* @param data
|
|
@@ -661,25 +683,17 @@ var Data = /** @class */ (function (_super) {
|
|
|
661
683
|
* | :--- | :-- | :-- |
|
|
662
684
|
* | request | object | Only allow "system_info" for now |
|
|
663
685
|
*/
|
|
664
|
-
|
|
665
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetMetrics', {
|
|
674
|
-
request: JSON.stringify(data.request),
|
|
675
|
-
}, data.timeout || this.timeout)];
|
|
676
|
-
case 1:
|
|
677
|
-
res = _a.sent();
|
|
678
|
-
return [2 /*return*/, __assign(__assign({}, res), { response: JSON.parse(res.response) })];
|
|
679
|
-
}
|
|
680
|
-
});
|
|
686
|
+
getMetric(data) {
|
|
687
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
688
|
+
if (!data || !data.request || !data.request.metric_type) {
|
|
689
|
+
throw new Error(__1.ERROR_REASONS.GET_METRIC_CHECK_PARAMS);
|
|
690
|
+
}
|
|
691
|
+
const res = yield (0, __1.promisify)(this.client, 'GetMetrics', {
|
|
692
|
+
request: JSON.stringify(data.request),
|
|
693
|
+
}, data.timeout || this.timeout);
|
|
694
|
+
return Object.assign(Object.assign({}, res), { response: JSON.parse(res.response) });
|
|
681
695
|
});
|
|
682
|
-
}
|
|
696
|
+
}
|
|
683
697
|
/**
|
|
684
698
|
* Get flush state by segment ids
|
|
685
699
|
*
|
|
@@ -704,23 +718,15 @@ var Data = /** @class */ (function (_super) {
|
|
|
704
718
|
* });
|
|
705
719
|
* ```
|
|
706
720
|
*/
|
|
707
|
-
|
|
708
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
throw new Error(__1.ERROR_REASONS.GET_FLUSH_STATE_CHECK_PARAMS);
|
|
715
|
-
}
|
|
716
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetFlushState', data, data.timeout || this.timeout)];
|
|
717
|
-
case 1:
|
|
718
|
-
res = _a.sent();
|
|
719
|
-
return [2 /*return*/, res];
|
|
720
|
-
}
|
|
721
|
-
});
|
|
721
|
+
getFlushState(data) {
|
|
722
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
723
|
+
if (!data || !data.segmentIDs) {
|
|
724
|
+
throw new Error(__1.ERROR_REASONS.GET_FLUSH_STATE_CHECK_PARAMS);
|
|
725
|
+
}
|
|
726
|
+
const res = yield (0, __1.promisify)(this.client, 'GetFlushState', data, data.timeout || this.timeout);
|
|
727
|
+
return res;
|
|
722
728
|
});
|
|
723
|
-
}
|
|
729
|
+
}
|
|
724
730
|
/**
|
|
725
731
|
* Do load balancing operation from source query node to destination query node.
|
|
726
732
|
* Only work in cluster milvus.
|
|
@@ -737,7 +743,7 @@ var Data = /** @class */ (function (_super) {
|
|
|
737
743
|
* | Property | Description |
|
|
738
744
|
* | :--- | :-- |
|
|
739
745
|
* | status | { error_code: number,reason:string } |
|
|
740
|
-
* | infos | segments
|
|
746
|
+
* | infos | segments information |
|
|
741
747
|
*
|
|
742
748
|
*
|
|
743
749
|
* #### Example
|
|
@@ -748,23 +754,15 @@ var Data = /** @class */ (function (_super) {
|
|
|
748
754
|
* });
|
|
749
755
|
* ```
|
|
750
756
|
*/
|
|
751
|
-
|
|
752
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
throw new Error(__1.ERROR_REASONS.LOAD_BALANCE_CHECK_PARAMS);
|
|
759
|
-
}
|
|
760
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'LoadBalance', data, data.timeout || this.timeout)];
|
|
761
|
-
case 1:
|
|
762
|
-
res = _a.sent();
|
|
763
|
-
return [2 /*return*/, res];
|
|
764
|
-
}
|
|
765
|
-
});
|
|
757
|
+
loadBalance(data) {
|
|
758
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
759
|
+
if (!data || !data.src_nodeID) {
|
|
760
|
+
throw new Error(__1.ERROR_REASONS.LOAD_BALANCE_CHECK_PARAMS);
|
|
761
|
+
}
|
|
762
|
+
const res = yield (0, __1.promisify)(this.client, 'LoadBalance', data, data.timeout || this.timeout);
|
|
763
|
+
return res;
|
|
766
764
|
});
|
|
767
|
-
}
|
|
765
|
+
}
|
|
768
766
|
/**
|
|
769
767
|
* Notifies Proxy to return segments information from query nodes.
|
|
770
768
|
*
|
|
@@ -790,23 +788,15 @@ var Data = /** @class */ (function (_super) {
|
|
|
790
788
|
* });
|
|
791
789
|
* ```
|
|
792
790
|
*/
|
|
793
|
-
|
|
794
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
801
|
-
}
|
|
802
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'GetQuerySegmentInfo', data, data.timeout || this.timeout)];
|
|
803
|
-
case 1:
|
|
804
|
-
res = _a.sent();
|
|
805
|
-
return [2 /*return*/, res];
|
|
806
|
-
}
|
|
807
|
-
});
|
|
791
|
+
getQuerySegmentInfo(data) {
|
|
792
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
793
|
+
if (!data || !data.collectionName) {
|
|
794
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
795
|
+
}
|
|
796
|
+
const res = yield (0, __1.promisify)(this.client, 'GetQuerySegmentInfo', data, data.timeout || this.timeout);
|
|
797
|
+
return res;
|
|
808
798
|
});
|
|
809
|
-
}
|
|
799
|
+
}
|
|
810
800
|
/**
|
|
811
801
|
* Import data from files
|
|
812
802
|
*
|
|
@@ -834,26 +824,18 @@ var Data = /** @class */ (function (_super) {
|
|
|
834
824
|
* ```
|
|
835
825
|
*/
|
|
836
826
|
/* istanbul ignore next */
|
|
837
|
-
|
|
838
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
throw new Error(__1.ERROR_REASONS.IMPORT_FILE_CHECK);
|
|
848
|
-
}
|
|
849
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'Import', __assign(__assign({}, data), { options: data.options || [] }), data.timeout || this.timeout)];
|
|
850
|
-
case 1:
|
|
851
|
-
res = _a.sent();
|
|
852
|
-
return [2 /*return*/, res];
|
|
853
|
-
}
|
|
854
|
-
});
|
|
827
|
+
bulkInsert(data) {
|
|
828
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
829
|
+
if (!data || !data.collection_name) {
|
|
830
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
831
|
+
}
|
|
832
|
+
if (!data || !data.files) {
|
|
833
|
+
throw new Error(__1.ERROR_REASONS.IMPORT_FILE_CHECK);
|
|
834
|
+
}
|
|
835
|
+
const res = yield (0, __1.promisify)(this.client, 'Import', Object.assign(Object.assign({}, data), { options: data.options || [] }), data.timeout || this.timeout);
|
|
836
|
+
return res;
|
|
855
837
|
});
|
|
856
|
-
}
|
|
838
|
+
}
|
|
857
839
|
/**
|
|
858
840
|
* List import tasks
|
|
859
841
|
*
|
|
@@ -884,24 +866,15 @@ var Data = /** @class */ (function (_super) {
|
|
|
884
866
|
* ```
|
|
885
867
|
*/
|
|
886
868
|
/* istanbul ignore next */
|
|
887
|
-
|
|
888
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
895
|
-
}
|
|
896
|
-
return [4 /*yield*/, (0, utils_1.promisify)(this.client, 'ListImportTasks', __assign(__assign({}, data), { limit: data.limit || 0 }), data.timeout || this.timeout)];
|
|
897
|
-
case 1:
|
|
898
|
-
res = _a.sent();
|
|
899
|
-
return [2 /*return*/, res];
|
|
900
|
-
}
|
|
901
|
-
});
|
|
869
|
+
listImportTasks(data) {
|
|
870
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
871
|
+
if (!data || !data.collection_name) {
|
|
872
|
+
throw new Error(__1.ERROR_REASONS.COLLECTION_NAME_IS_REQUIRED);
|
|
873
|
+
}
|
|
874
|
+
const res = yield (0, __1.promisify)(this.client, 'ListImportTasks', Object.assign(Object.assign({}, data), { limit: data.limit || 0 }), data.timeout || this.timeout);
|
|
875
|
+
return res;
|
|
902
876
|
});
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
}(Collection_1.Collection));
|
|
877
|
+
}
|
|
878
|
+
}
|
|
906
879
|
exports.Data = Data;
|
|
907
880
|
//# sourceMappingURL=Data.js.map
|