@zilliz/milvus2-sdk-node 2.2.8 → 2.2.10
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 +83 -7
- package/dist/milvus/MilvusClient.d.ts +24 -12
- package/dist/milvus/MilvusClient.js +30 -124
- package/dist/milvus/MilvusClient.js.map +1 -1
- package/dist/milvus/const/Milvus.d.ts +3 -0
- package/dist/milvus/const/Milvus.js +4 -1
- package/dist/milvus/const/Milvus.js.map +1 -1
- package/dist/milvus/const/index.d.ts +2 -0
- package/dist/milvus/const/index.js +20 -0
- package/dist/milvus/const/index.js.map +1 -0
- package/dist/milvus/{BaseClient.d.ts → grpc/BaseClient.d.ts} +10 -4
- package/dist/milvus/grpc/BaseClient.js +64 -0
- package/dist/milvus/grpc/BaseClient.js.map +1 -0
- package/dist/milvus/{Collection.d.ts → grpc/Collection.d.ts} +1 -1
- package/dist/milvus/{Collection.js → grpc/Collection.js} +35 -35
- package/dist/milvus/grpc/Collection.js.map +1 -0
- package/dist/milvus/{Data.d.ts → grpc/Data.d.ts} +1 -3
- package/dist/milvus/{Data.js → grpc/Data.js} +66 -68
- package/dist/milvus/grpc/Data.js.map +1 -0
- package/dist/milvus/grpc/GrpcClient.d.ts +36 -0
- package/dist/milvus/grpc/GrpcClient.js +219 -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/{MilvusIndex.js → grpc/MilvusIndex.js} +7 -7
- package/dist/milvus/grpc/MilvusIndex.js.map +1 -0
- package/dist/milvus/{Partition.d.ts → grpc/Partition.d.ts} +1 -1
- package/dist/milvus/{Partition.js → grpc/Partition.js} +11 -11
- package/dist/milvus/grpc/Partition.js.map +1 -0
- package/dist/milvus/{Resource.d.ts → grpc/Resource.d.ts} +1 -1
- package/dist/milvus/{Resource.js → grpc/Resource.js} +10 -10
- package/dist/milvus/grpc/Resource.js.map +1 -0
- package/dist/milvus/{User.d.ts → grpc/User.d.ts} +1 -1
- package/dist/milvus/{User.js → grpc/User.js} +25 -24
- package/dist/milvus/grpc/User.js.map +1 -0
- package/dist/milvus/index.d.ts +4 -11
- package/dist/milvus/index.js +6 -12
- package/dist/milvus/index.js.map +1 -1
- package/dist/milvus/types/Client.d.ts +7 -1
- package/dist/milvus/types/Collection.d.ts +1 -1
- package/dist/milvus/types/Common.d.ts +1 -1
- package/dist/milvus/types/Index.d.ts +10 -59
- package/dist/milvus/types/Index.js +25 -0
- package/dist/milvus/types/Index.js.map +1 -1
- package/dist/milvus/types/MilvusIndex.d.ts +60 -0
- package/dist/milvus/types/MilvusIndex.js +3 -0
- package/dist/milvus/types/MilvusIndex.js.map +1 -0
- package/dist/milvus/types/User.d.ts +1 -1
- package/dist/milvus/types.d.ts +1 -1
- package/dist/milvus/types.js +2 -1
- package/dist/milvus/types.js.map +1 -1
- package/dist/proto/proto/google/protobuf/descriptor.proto +1 -1
- package/dist/sdk.json +1 -1
- package/dist/utils/Format.d.ts +7 -0
- package/dist/utils/Format.js +12 -1
- package/dist/utils/Format.js.map +1 -1
- package/dist/utils/Grpc.d.ts +14 -0
- package/dist/utils/Grpc.js +107 -1
- package/dist/utils/Grpc.js.map +1 -1
- package/dist/utils/Validate.d.ts +11 -0
- package/dist/utils/Validate.js +21 -1
- package/dist/utils/Validate.js.map +1 -1
- package/dist/utils/test.d.ts +14 -0
- package/dist/utils/test.js +14 -0
- package/dist/utils/test.js.map +1 -1
- package/package.json +2 -2
- package/dist/milvus/BaseClient.js +0 -87
- package/dist/milvus/BaseClient.js.map +0 -1
- package/dist/milvus/Collection.js.map +0 -1
- package/dist/milvus/Data.js.map +0 -1
- package/dist/milvus/MilvusIndex.js.map +0 -1
- package/dist/milvus/Partition.js.map +0 -1
- package/dist/milvus/Resource.js.map +0 -1
- 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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[](https://badges.aleen42.com/src/typescript.svg)
|
|
2
|
-
[](https://img.shields.io/npm/v/@zilliz/milvus2-sdk-node)
|
|
3
|
-
[](https://img.shields.io/npm/dw/@zilliz/milvus2-sdk-node)
|
|
2
|
+
[](https://img.shields.io/npm/v/@zilliz/milvus2-sdk-node)
|
|
3
|
+
[](https://img.shields.io/npm/dw/@zilliz/milvus2-sdk-node)
|
|
4
4
|
[](https://codecov.io/gh/milvus-io/milvus-sdk-node)
|
|
5
5
|
|
|
6
6
|
# Milvus2-sdk-node
|
|
@@ -78,14 +78,29 @@ Create a new app.js file and add the following code to try out some basic vector
|
|
|
78
78
|
```javascript
|
|
79
79
|
import { MilvusClient, DataType } from '@zilliz/milvus2-sdk-node';
|
|
80
80
|
|
|
81
|
-
const
|
|
81
|
+
const address = 'your-milvus-ip';
|
|
82
|
+
const username = 'your-milvus-username'; // optional username
|
|
83
|
+
const password = 'your-milvus-password'; // optional password
|
|
84
|
+
const ssl = false; // secure or not
|
|
82
85
|
|
|
83
86
|
// connect to milvus
|
|
84
|
-
const client = new MilvusClient(
|
|
87
|
+
const client = new MilvusClient({ address, ssl, username, password });
|
|
85
88
|
```
|
|
86
89
|
|
|
90
|
+
| Parameters | Description | Type | Example |
|
|
91
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------------------ | ------- | ------------------- |
|
|
92
|
+
| address | The Milvus IP address | String | '192.168.0.1:19530' |
|
|
93
|
+
| ssl? | SSL connection. It is false by default. | Boolean | false |
|
|
94
|
+
| username? | The username used to connect to Milvus | String | milvus |
|
|
95
|
+
| address? | The password used to connect to Milvus | String | milvus |
|
|
96
|
+
| maxRetries? | The number of retries for the grpc method, by default: 3 | Number | 3 |
|
|
97
|
+
| retryDelay? | The delay between attempts at retrying a failed grpc method in ms, by default: 30 | Number | 30 |
|
|
98
|
+
| channelOptions? | an optional configuration object that can be passed to a gRPC client when creating a channel to connect to a gRPC server | Number | 30 |
|
|
99
|
+
|
|
87
100
|
### define schema for collection
|
|
88
101
|
|
|
102
|
+
The code shows an example of how to define a schema for a collection in Milvus using the Milvus Node SDK. A schema defines the properties of a collection, such as the names and data types of the fields that make up the vectors.
|
|
103
|
+
|
|
89
104
|
```javascript
|
|
90
105
|
// define schema
|
|
91
106
|
const collection_name = `book`;
|
|
@@ -112,6 +127,20 @@ const schema = [
|
|
|
112
127
|
];
|
|
113
128
|
```
|
|
114
129
|
|
|
130
|
+
In the code, the schema variable is defined as an array of objects, where each object represents a field in the collection. The fields are defined using the following properties:
|
|
131
|
+
|
|
132
|
+
`name`: The name of the field, which must be unique within the collection.
|
|
133
|
+
|
|
134
|
+
`description`: A description of the field, which can be used to provide additional information about the field.
|
|
135
|
+
|
|
136
|
+
`data_type`: The data type of the field, which can be one of several predefined data types such as Int64 or FloatVector.
|
|
137
|
+
|
|
138
|
+
`is_primary_key`: A boolean flag that indicates whether the field is a primary key. Primary keys are unique identifiers for each vector in the collection, and can be used to efficiently retrieve specific vectors.
|
|
139
|
+
|
|
140
|
+
`autoID`: A boolean flag that indicates whether the primary key is automatically generated by Milvus.
|
|
141
|
+
|
|
142
|
+
`dim`: The dimensionality of the vector field. For fields of type FloatVector, this specifies the number of dimensions in each vector.
|
|
143
|
+
|
|
115
144
|
### create collection
|
|
116
145
|
|
|
117
146
|
```javascript
|
|
@@ -124,6 +153,8 @@ await client.createCollection({
|
|
|
124
153
|
|
|
125
154
|
### prepare data
|
|
126
155
|
|
|
156
|
+
When using the Milvus Node SDK to insert data into a collection, it's important to ensure that the data format of the input matches the schema defined for the collection. The data format used by the Milvus Node SDK consists of an array of objects, where each object represents an entity. Typically, each object contains a unique identifier for the entity, which can be an integer or string, and a vector field that stores the feature values as an array of floating-point numbers.
|
|
157
|
+
|
|
127
158
|
```javascript
|
|
128
159
|
// generate mock data
|
|
129
160
|
const fields_data = [];
|
|
@@ -143,6 +174,8 @@ for (let i = 0; i < 1000; i++) {
|
|
|
143
174
|
|
|
144
175
|
### insert data into collection
|
|
145
176
|
|
|
177
|
+
Once we have the data, you can insert data into the collection.
|
|
178
|
+
|
|
146
179
|
```javascript
|
|
147
180
|
await client.insert({
|
|
148
181
|
collection_name,
|
|
@@ -150,7 +183,9 @@ await client.insert({
|
|
|
150
183
|
});
|
|
151
184
|
```
|
|
152
185
|
|
|
153
|
-
### create index
|
|
186
|
+
### create index
|
|
187
|
+
|
|
188
|
+
By creating an index and loading the collection into memory, you can improve the performance of search and retrieval operations in Milvus, making it faster and more efficient to work with large-scale datasets.
|
|
154
189
|
|
|
155
190
|
```javascript
|
|
156
191
|
// create index
|
|
@@ -158,9 +193,31 @@ await client.createIndex({
|
|
|
158
193
|
collection_name,
|
|
159
194
|
field_name: 'book_intro',
|
|
160
195
|
index_name: 'myindex',
|
|
161
|
-
index_type: '
|
|
196
|
+
index_type: 'HNSW',
|
|
197
|
+
param: { ef: 5 },
|
|
162
198
|
metric_type: 'L2',
|
|
163
199
|
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Milvus supports [several different types of indexes](https://milvus.io/docs/index.md), each of which is optimized for different use cases and data distributions. Some of the most commonly used index types in Milvus include IVF_FLAT, IVF_SQ8, IVF_PQ, and HNSW. When creating an index in Milvus, you must choose an appropriate index type based on your specific use case and data distribution.
|
|
203
|
+
|
|
204
|
+
`collection_name`: The name of the collection to create the index for.
|
|
205
|
+
|
|
206
|
+
`field_name`: The name of the field to create the index on.
|
|
207
|
+
|
|
208
|
+
`index_name`: The name of the index to create.
|
|
209
|
+
|
|
210
|
+
`index_type`: The type of index to create.
|
|
211
|
+
|
|
212
|
+
`param`: The index build parameters, please refer to the [index docs](https://milvus.io/docs/index.md).
|
|
213
|
+
|
|
214
|
+
`metric_type`: The distance metric to use when computing the similarity between vectors. In this case, the metric type is set to L2, which is a commonly used metric for computing the Euclidean distance between vectors.
|
|
215
|
+
|
|
216
|
+
### load collection
|
|
217
|
+
|
|
218
|
+
When you create a collection in Milvus, the collection data is initially stored on disk, and it is not immediately available for search and retrieval. In order to search or retrieve data from the collection, you must first load the collection into memory using the loadCollectionSync method.
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
164
221
|
// load collection
|
|
165
222
|
await client.loadCollectionSync({
|
|
166
223
|
collection_name,
|
|
@@ -169,6 +226,8 @@ await client.loadCollectionSync({
|
|
|
169
226
|
|
|
170
227
|
### vector search
|
|
171
228
|
|
|
229
|
+
Now you can perform vector search on your collection.
|
|
230
|
+
|
|
172
231
|
```javascript
|
|
173
232
|
// Generate a random search vector
|
|
174
233
|
const searchVector = [...Array(dim)].map(() => Math.random());
|
|
@@ -176,7 +235,7 @@ const searchVector = [...Array(dim)].map(() => Math.random());
|
|
|
176
235
|
// Perform a vector search on the collection
|
|
177
236
|
const res = await client.search({
|
|
178
237
|
collection_name, // required, the collection name
|
|
179
|
-
|
|
238
|
+
vector: [0.1, 0.2, 0.3, 0.4], // required, vector used to compare other vectors in milvus
|
|
180
239
|
filter: 'word_count > 0', // optional, filter
|
|
181
240
|
params: { nprobe: 64 }, // optional, specify the search parameters
|
|
182
241
|
limit: 1, // specify the number of nearest neighbors to return
|
|
@@ -185,6 +244,23 @@ const res = await client.search({
|
|
|
185
244
|
});
|
|
186
245
|
```
|
|
187
246
|
|
|
247
|
+
The code snippet performs a vector search on the collection.
|
|
248
|
+
|
|
249
|
+
First, a random search vector is generated. Then, the `client.search()` method is called with several parameters:
|
|
250
|
+
`collection_name`: Required. Specifies the name of the Milvus collection to search.
|
|
251
|
+
|
|
252
|
+
`vectors`: Required. Specifies the vector used to compare other vectors in Milvus. The example code passes an array of floating-point numbers as the vector.
|
|
253
|
+
|
|
254
|
+
`filter` or `expr`: Optional. Specifies a filter to apply to the search query. The example code passes a filter that only includes vectors where the word_count field is greater than 0.
|
|
255
|
+
|
|
256
|
+
`params`: Optional. Specifies additional search parameters. The example code sets nprobe to 64, which controls the number of clusters to search during the query. By default, nothing will be set.
|
|
257
|
+
|
|
258
|
+
`limit` or `topk`: Optional. Specifies the number of nearest neighbors to return. The example code sets this to 1. By default, it will be `100`
|
|
259
|
+
|
|
260
|
+
`metric_type`: Optional. Specifies the metric used to calculate the similarity of two vectors. The example code sets this to `"L2"`. By default, it will be `"L2"`.
|
|
261
|
+
|
|
262
|
+
`output_fields`: Optional. Specifies which fields to include in the search results. The example code specifies the `book_id` and `word_count` fields, by default the node sdk will output all fields.
|
|
263
|
+
|
|
188
264
|
## Next Steps
|
|
189
265
|
|
|
190
266
|
- [What is Milvus](https://milvus.io/)
|
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { ChannelOptions } from '@grpc/grpc-js';
|
|
2
|
+
import { GRPCClient, ClientConfig } from '.';
|
|
3
|
+
/**
|
|
4
|
+
* Milvus Client class that extends GRPCClient and handles communication with Milvus server.
|
|
5
|
+
*/
|
|
6
|
+
export declare class MilvusClient extends GRPCClient {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the SDK information.
|
|
9
|
+
* SDK information will be generated on the building phase
|
|
10
|
+
* @returns Object containing SDK version and recommended Milvus version.
|
|
11
|
+
*/
|
|
4
12
|
static get sdkInfo(): {
|
|
5
13
|
version: string;
|
|
6
14
|
recommandMilvus: string;
|
|
7
15
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new instance of MilvusClient.
|
|
18
|
+
* @param configOrAddress The Milvus server's address or client configuration object.
|
|
19
|
+
* @param ssl Whether to use SSL or not.
|
|
20
|
+
* @param username The username for authentication.
|
|
21
|
+
* @param password The password for authentication.
|
|
22
|
+
* @param channelOptions Additional channel options for gRPC.
|
|
23
|
+
*/
|
|
24
|
+
constructor(configOrAddress: ClientConfig | string, ssl?: boolean, username?: string, password?: string, channelOptions?: ChannelOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Overloads the original connect function in GRPCClient to add additional functionality.
|
|
27
|
+
*/
|
|
28
|
+
connect(): void;
|
|
17
29
|
}
|
|
@@ -14,56 +14,40 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
19
|
};
|
|
56
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
21
|
exports.MilvusClient = void 0;
|
|
22
|
+
var _1 = require(".");
|
|
58
23
|
var sdk_json_1 = __importDefault(require("../sdk.json"));
|
|
59
|
-
|
|
60
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Milvus Client class that extends GRPCClient and handles communication with Milvus server.
|
|
26
|
+
*/
|
|
61
27
|
var MilvusClient = /** @class */ (function (_super) {
|
|
62
28
|
__extends(MilvusClient, _super);
|
|
63
|
-
|
|
64
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new instance of MilvusClient.
|
|
31
|
+
* @param configOrAddress The Milvus server's address or client configuration object.
|
|
32
|
+
* @param ssl Whether to use SSL or not.
|
|
33
|
+
* @param username The username for authentication.
|
|
34
|
+
* @param password The password for authentication.
|
|
35
|
+
* @param channelOptions Additional channel options for gRPC.
|
|
36
|
+
*/
|
|
37
|
+
function MilvusClient(configOrAddress, ssl, username, password, channelOptions) {
|
|
38
|
+
var _this =
|
|
39
|
+
// setup the configuration
|
|
40
|
+
_super.call(this, configOrAddress, ssl, username, password, channelOptions) || this;
|
|
41
|
+
// connect here
|
|
42
|
+
_this.connect();
|
|
43
|
+
return _this;
|
|
65
44
|
}
|
|
66
45
|
Object.defineProperty(MilvusClient, "sdkInfo", {
|
|
46
|
+
/**
|
|
47
|
+
* Returns the SDK information.
|
|
48
|
+
* SDK information will be generated on the building phase
|
|
49
|
+
* @returns Object containing SDK version and recommended Milvus version.
|
|
50
|
+
*/
|
|
67
51
|
get: function () {
|
|
68
52
|
return {
|
|
69
53
|
version: sdk_json_1.default.version,
|
|
@@ -73,91 +57,13 @@ var MilvusClient = /** @class */ (function (_super) {
|
|
|
73
57
|
enumerable: false,
|
|
74
58
|
configurable: true
|
|
75
59
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return this;
|
|
82
|
-
},
|
|
83
|
-
enumerable: false,
|
|
84
|
-
configurable: true
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(MilvusClient.prototype, "partitionManager", {
|
|
87
|
-
get: function () {
|
|
88
|
-
/* istanbul ignore next */
|
|
89
|
-
console.warn("partitionManager are no longer necessary, you can call methods directly on the client object.");
|
|
90
|
-
return this;
|
|
91
|
-
},
|
|
92
|
-
enumerable: false,
|
|
93
|
-
configurable: true
|
|
94
|
-
});
|
|
95
|
-
Object.defineProperty(MilvusClient.prototype, "indexManager", {
|
|
96
|
-
get: function () {
|
|
97
|
-
/* istanbul ignore next */
|
|
98
|
-
console.warn("indexManager are no longer necessary, you can call methods directly on the client object.");
|
|
99
|
-
return this;
|
|
100
|
-
},
|
|
101
|
-
enumerable: false,
|
|
102
|
-
configurable: true
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(MilvusClient.prototype, "dataManager", {
|
|
105
|
-
get: function () {
|
|
106
|
-
/* istanbul ignore next */
|
|
107
|
-
console.warn("dataManager are no longer necessary, you can call methods directly on the client object.");
|
|
108
|
-
return this;
|
|
109
|
-
},
|
|
110
|
-
enumerable: false,
|
|
111
|
-
configurable: true
|
|
112
|
-
});
|
|
113
|
-
Object.defineProperty(MilvusClient.prototype, "resourceManager", {
|
|
114
|
-
get: function () {
|
|
115
|
-
/* istanbul ignore next */
|
|
116
|
-
console.warn("resourceManager are no longer necessary, you can call methods directly on the client object.");
|
|
117
|
-
return this;
|
|
118
|
-
},
|
|
119
|
-
enumerable: false,
|
|
120
|
-
configurable: true
|
|
121
|
-
});
|
|
122
|
-
Object.defineProperty(MilvusClient.prototype, "userManager", {
|
|
123
|
-
get: function () {
|
|
124
|
-
/* istanbul ignore next */
|
|
125
|
-
console.warn("userManager are no longer necessary, you can call methods directly on the client object.");
|
|
126
|
-
return this;
|
|
127
|
-
},
|
|
128
|
-
enumerable: false,
|
|
129
|
-
configurable: true
|
|
130
|
-
});
|
|
131
|
-
// This method closes the gRPC client connection and returns the connectivity state of the channel.
|
|
132
|
-
MilvusClient.prototype.closeConnection = function () {
|
|
133
|
-
// Close the gRPC client connection
|
|
134
|
-
this.grpcClient.close();
|
|
135
|
-
// grpc client closed -> 4, connected -> 0
|
|
136
|
-
return this.grpcClient.getChannel().getConnectivityState(true);
|
|
137
|
-
};
|
|
138
|
-
// This method returns the version of the Milvus server.
|
|
139
|
-
MilvusClient.prototype.getVersion = function () {
|
|
140
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
-
return __generator(this, function (_a) {
|
|
142
|
-
switch (_a.label) {
|
|
143
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'GetVersion', {}, this.timeout)];
|
|
144
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
// This method checks the health of the Milvus server.
|
|
150
|
-
MilvusClient.prototype.checkHealth = function () {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
return __generator(this, function (_a) {
|
|
153
|
-
switch (_a.label) {
|
|
154
|
-
case 0: return [4 /*yield*/, (0, utils_1.promisify)(this.grpcClient, 'CheckHealth', {}, this.timeout)];
|
|
155
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
60
|
+
/**
|
|
61
|
+
* Overloads the original connect function in GRPCClient to add additional functionality.
|
|
62
|
+
*/
|
|
63
|
+
MilvusClient.prototype.connect = function () {
|
|
64
|
+
_super.prototype.connect.call(this);
|
|
159
65
|
};
|
|
160
66
|
return MilvusClient;
|
|
161
|
-
}(
|
|
67
|
+
}(_1.GRPCClient));
|
|
162
68
|
exports.MilvusClient = MilvusClient;
|
|
163
69
|
//# sourceMappingURL=MilvusClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MilvusClient.js","sourceRoot":"","sources":["../../milvus/MilvusClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MilvusClient.js","sourceRoot":"","sources":["../../milvus/MilvusClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,sBAA6C;AAC7C,yDAAkC;AAElC;;GAEG;AACH;IAAkC,gCAAU;IAa1C;;;;;;;OAOG;IACH,sBACE,eAAsC,EACtC,GAAa,EACb,QAAiB,EACjB,QAAiB,EACjB,cAA+B;QALjC;QAOE,0BAA0B;QAC1B,kBAAM,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC,SAGhE;QAFC,eAAe;QACf,KAAI,CAAC,OAAO,EAAE,CAAC;;IACjB,CAAC;IA1BD,sBAAW,uBAAO;QALlB;;;;WAIG;aACH;YACE,OAAO;gBACL,OAAO,EAAE,kBAAO,CAAC,OAAO;gBACxB,eAAe,EAAE,kBAAO,CAAC,aAAa;aACvC,CAAC;QACJ,CAAC;;;OAAA;IAuBD;;OAEG;IACH,8BAAO,GAAP;QACE,iBAAM,OAAO,WAAE,CAAC;IAClB,CAAC;IACH,mBAAC;AAAD,CAAC,AAxCD,CAAkC,aAAU,GAwC3C;AAxCY,oCAAY"}
|
|
@@ -2,6 +2,9 @@ export declare const DEFAULT_MILVUS_PORT = 19530;
|
|
|
2
2
|
export declare const DEFAULT_CONNECT_TIMEOUT: number;
|
|
3
3
|
export declare const DEFAULT_TOPK = 100;
|
|
4
4
|
export declare const DEFAULT_METRIC_TYPE = "L2";
|
|
5
|
+
export declare const DEFAULT_MAX_RETRIES = 3;
|
|
6
|
+
export declare const DEFAULT_RETRY_DELAY = 30;
|
|
7
|
+
export declare const DEFAULT_DEBUG = false;
|
|
5
8
|
export declare enum ConsistencyLevelEnum {
|
|
6
9
|
Strong = 0,
|
|
7
10
|
Session = 1,
|
|
@@ -11,11 +11,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.LoadState = exports.DEFAULT_RESOURCE_GROUP = exports.Privileges = exports.UserPrivileges = exports.GlobalPrivileges = exports.CollectionPrivileges = exports.RbacObjects = exports.Roles = exports.OperatePrivilegeType = exports.OperateUserRoleType = exports.DataTypeMap = exports.DataType = exports.MsgType = exports.IndexType = exports.MetricType = exports.StateCode = exports.ObjectPrivilege = exports.ObjectType = exports.ImportState = exports.CompactionState = exports.SegmentState = exports.ConsistencyLevelEnum = exports.DEFAULT_METRIC_TYPE = exports.DEFAULT_TOPK = exports.DEFAULT_CONNECT_TIMEOUT = exports.DEFAULT_MILVUS_PORT = void 0;
|
|
14
|
+
exports.LoadState = exports.DEFAULT_RESOURCE_GROUP = exports.Privileges = exports.UserPrivileges = exports.GlobalPrivileges = exports.CollectionPrivileges = exports.RbacObjects = exports.Roles = exports.OperatePrivilegeType = exports.OperateUserRoleType = exports.DataTypeMap = exports.DataType = exports.MsgType = exports.IndexType = exports.MetricType = exports.StateCode = exports.ObjectPrivilege = exports.ObjectType = exports.ImportState = exports.CompactionState = exports.SegmentState = exports.ConsistencyLevelEnum = exports.DEFAULT_DEBUG = exports.DEFAULT_RETRY_DELAY = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_METRIC_TYPE = exports.DEFAULT_TOPK = exports.DEFAULT_CONNECT_TIMEOUT = exports.DEFAULT_MILVUS_PORT = void 0;
|
|
15
15
|
exports.DEFAULT_MILVUS_PORT = 19530; // default milvus port
|
|
16
16
|
exports.DEFAULT_CONNECT_TIMEOUT = 10 * 1000; // 10s
|
|
17
17
|
exports.DEFAULT_TOPK = 100; // default topk
|
|
18
18
|
exports.DEFAULT_METRIC_TYPE = 'L2';
|
|
19
|
+
exports.DEFAULT_MAX_RETRIES = 3; // max retry time
|
|
20
|
+
exports.DEFAULT_RETRY_DELAY = 30; // retry delay, 30ms
|
|
21
|
+
exports.DEFAULT_DEBUG = false;
|
|
19
22
|
var ErrorCode;
|
|
20
23
|
(function (ErrorCode) {
|
|
21
24
|
ErrorCode[ErrorCode["Success"] = 0] = "Success";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Milvus.js","sourceRoot":"","sources":["../../../milvus/const/Milvus.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAa,QAAA,mBAAmB,GAAG,KAAK,CAAC,CAAC,sBAAsB;AACnD,QAAA,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM;AAC3C,QAAA,YAAY,GAAG,GAAG,CAAC,CAAC,eAAe;AACnC,QAAA,mBAAmB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"Milvus.js","sourceRoot":"","sources":["../../../milvus/const/Milvus.ts"],"names":[],"mappings":";;;;;;;;;;;;;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7B,CAAC,EAhBW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAgB/B;AAED,IAAY,gBAUX;AAVD,WAAY,gBAAgB;IAC1B,6BAAS,CAAA;IACT,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,6DAAyC,CAAA;IACzC,uDAAmC,CAAA;IACnC,uDAAmC,CAAA;IACnC,mDAA+B,CAAA;IAC/B,uDAAmC,CAAA;IACnC,uDAAmC,CAAA;AACrC,CAAC,EAVW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAU3B;AAED,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,2CAAyB,CAAA;IACzB,2CAAyB,CAAA;AAC3B,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAEY,QAAA,UAAU,kCAClB,oBAAoB,GACpB,cAAc,GACd,gBAAgB,EACnB;AAEW,QAAA,sBAAsB,GAAG,0BAA0B,CAAC;AAEjE,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,oDAAuC,CAAA;IACvC,kDAAqC,CAAA;IACrC,kDAAqC,CAAA;IACrC,gDAAmC,CAAA;AACrC,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// consts
|
|
18
|
+
__exportStar(require("./ErrorReason"), exports);
|
|
19
|
+
__exportStar(require("./Milvus"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../milvus/const/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS;AACT,gDAA8B;AAC9B,2CAAyB"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { Root } from 'protobufjs';
|
|
2
2
|
import { Client, ChannelOptions } from '@grpc/grpc-js';
|
|
3
|
-
import {
|
|
3
|
+
import { ClientConfig } from '..';
|
|
4
|
+
/**
|
|
5
|
+
* Base gRPC client, setup all configuration here
|
|
6
|
+
*/
|
|
4
7
|
export declare class BaseClient {
|
|
8
|
+
client: Client | undefined;
|
|
9
|
+
protoPath: string;
|
|
5
10
|
schemaProto: Root;
|
|
6
11
|
milvusProto: Root;
|
|
7
|
-
|
|
12
|
+
config: ClientConfig;
|
|
13
|
+
serviceName: string;
|
|
8
14
|
timeout: number;
|
|
9
15
|
/**
|
|
10
|
-
*
|
|
16
|
+
* Sets up the configuration object for the gRPC client.
|
|
11
17
|
*
|
|
12
18
|
* @param configOrAddress The configuration object or the Milvus address as a string.
|
|
13
19
|
* @param ssl Whether to use SSL or not. Default is false.
|
|
14
20
|
* @param username The username for authentication. Required if password is provided.
|
|
15
21
|
* @param password The password for authentication. Required if username is provided.
|
|
16
22
|
*/
|
|
17
|
-
constructor(configOrAddress:
|
|
23
|
+
constructor(configOrAddress: ClientConfig | string, ssl?: boolean, username?: string, password?: string, channelOptions?: ChannelOptions);
|
|
18
24
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseClient = void 0;
|
|
7
|
+
var path_1 = __importDefault(require("path"));
|
|
8
|
+
var protobufjs_1 = __importDefault(require("protobufjs"));
|
|
9
|
+
var __1 = require("..");
|
|
10
|
+
var utils_1 = require("../../utils");
|
|
11
|
+
// path
|
|
12
|
+
var protoPath = path_1.default.resolve(__dirname, '../../proto/proto/milvus.proto');
|
|
13
|
+
var schemaProtoPath = path_1.default.resolve(__dirname, '../../proto/proto/schema.proto');
|
|
14
|
+
/**
|
|
15
|
+
* Base gRPC client, setup all configuration here
|
|
16
|
+
*/
|
|
17
|
+
var BaseClient = /** @class */ (function () {
|
|
18
|
+
/**
|
|
19
|
+
* Sets up the configuration object for the gRPC client.
|
|
20
|
+
*
|
|
21
|
+
* @param configOrAddress The configuration object or the Milvus address as a string.
|
|
22
|
+
* @param ssl Whether to use SSL or not. Default is false.
|
|
23
|
+
* @param username The username for authentication. Required if password is provided.
|
|
24
|
+
* @param password The password for authentication. Required if username is provided.
|
|
25
|
+
*/
|
|
26
|
+
function BaseClient(configOrAddress, ssl, username, password, channelOptions) {
|
|
27
|
+
// The name of the Milvus service.
|
|
28
|
+
this.serviceName = 'milvus.proto.milvus.MilvusService';
|
|
29
|
+
// The timeout for connecting to the Milvus service.
|
|
30
|
+
this.timeout = __1.DEFAULT_CONNECT_TIMEOUT;
|
|
31
|
+
var config;
|
|
32
|
+
// If a configuration object is provided, use it. Otherwise, create a new object with the provided parameters.
|
|
33
|
+
if (typeof configOrAddress === 'object') {
|
|
34
|
+
config = configOrAddress;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
config = {
|
|
38
|
+
address: configOrAddress,
|
|
39
|
+
ssl: ssl,
|
|
40
|
+
username: username,
|
|
41
|
+
password: password,
|
|
42
|
+
channelOptions: channelOptions,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
// Check if the Milvus address is set.
|
|
46
|
+
if (!config.address) {
|
|
47
|
+
throw new Error(__1.ERROR_REASONS.MILVUS_ADDRESS_IS_REQUIRED);
|
|
48
|
+
}
|
|
49
|
+
// Assign the configuration object.
|
|
50
|
+
this.config = config;
|
|
51
|
+
// Load the Milvus protobuf.
|
|
52
|
+
this.protoPath = protoPath;
|
|
53
|
+
this.schemaProto = protobufjs_1.default.loadSync(schemaProtoPath);
|
|
54
|
+
this.milvusProto = protobufjs_1.default.loadSync(protoPath);
|
|
55
|
+
// Set up the timeout for connecting to the Milvus service.
|
|
56
|
+
this.timeout =
|
|
57
|
+
typeof config.timeout === 'string'
|
|
58
|
+
? (0, utils_1.parseTimeToken)(config.timeout)
|
|
59
|
+
: config.timeout || __1.DEFAULT_CONNECT_TIMEOUT;
|
|
60
|
+
}
|
|
61
|
+
return BaseClient;
|
|
62
|
+
}());
|
|
63
|
+
exports.BaseClient = BaseClient;
|
|
64
|
+
//# sourceMappingURL=BaseClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseClient.js","sourceRoot":"","sources":["../../../milvus/grpc/BaseClient.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwB;AACxB,0DAA4C;AAE5C,wBAA0E;AAC1E,qCAA6C;AAE7C,OAAO;AACP,IAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;AAC5E,IAAM,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;AAElF;;GAEG;AACH;IAiBE;;;;;;;OAOG;IACH,oBACE,eAAsC,EACtC,GAAa,EACb,QAAiB,EACjB,QAAiB,EACjB,cAA+B;QAnBjC,kCAAkC;QAClC,gBAAW,GAAW,mCAAmC,CAAC;QAE1D,oDAAoD;QACpD,YAAO,GAAW,2BAAuB,CAAC;QAiBxC,IAAI,MAAoB,CAAC;QAEzB,8GAA8G;QAC9G,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE;YACvC,MAAM,GAAG,eAAe,CAAC;SAC1B;aAAM;YACL,MAAM,GAAG;gBACP,OAAO,EAAE,eAAe;gBACxB,GAAG,KAAA;gBACH,QAAQ,UAAA;gBACR,QAAQ,UAAA;gBACR,cAAc,gBAAA;aACf,CAAC;SACH;QAED,sCAAsC;QACtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,iBAAa,CAAC,0BAA0B,CAAC,CAAC;SAC3D;QAED,mCAAmC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,4BAA4B;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,oBAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACtD,IAAI,CAAC,WAAW,GAAG,oBAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEhD,2DAA2D;QAC3D,IAAI,CAAC,OAAO;YACV,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;gBAChC,CAAC,CAAC,IAAA,sBAAc,EAAC,MAAM,CAAC,OAAO,CAAC;gBAChC,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,2BAAuB,CAAC;IAClD,CAAC;IACH,iBAAC;AAAD,CAAC,AAjED,IAiEC;AAjEY,gCAAU"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseClient } from './BaseClient';
|
|
2
|
-
import { CreateCollectionReq, DescribeCollectionReq, DropCollectionReq, GetCollectionStatisticsReq, LoadCollectionReq, ReleaseLoadCollectionReq, ShowCollectionsReq, HasCollectionReq, CreateAliasReq, DropAliasReq, AlterAliasReq, CompactReq, GetCompactionStateReq, GetCompactionPlansReq, GetReplicaReq, RenameCollectionReq, GetLoadingProgressReq, GetLoadStateReq, BoolResponse, ResStatus, CompactionResponse, DescribeCollectionResponse, GetCompactionPlansResponse, GetCompactionStateResponse, ShowCollectionsResponse, StatisticsResponse, ReplicasResponse, GetLoadingProgressResponse, GetLoadStateResponse } from '
|
|
2
|
+
import { CreateCollectionReq, DescribeCollectionReq, DropCollectionReq, GetCollectionStatisticsReq, LoadCollectionReq, ReleaseLoadCollectionReq, ShowCollectionsReq, HasCollectionReq, CreateAliasReq, DropAliasReq, AlterAliasReq, CompactReq, GetCompactionStateReq, GetCompactionPlansReq, GetReplicaReq, RenameCollectionReq, GetLoadingProgressReq, GetLoadStateReq, BoolResponse, ResStatus, CompactionResponse, DescribeCollectionResponse, GetCompactionPlansResponse, GetCompactionStateResponse, ShowCollectionsResponse, StatisticsResponse, ReplicasResponse, GetLoadingProgressResponse, GetLoadStateResponse } from '..';
|
|
3
3
|
/**
|
|
4
4
|
* @see [collection operation examples](https://github.com/milvus-io/milvus-sdk-node/blob/main/example/Collection.ts)
|
|
5
5
|
*/
|