diff --git a/milvus/grpc/Collection.ts b/milvus/grpc/Collection.ts index 99d963dd..4e9197ac 100644 --- a/milvus/grpc/Collection.ts +++ b/milvus/grpc/Collection.ts @@ -56,6 +56,7 @@ import { FieldSchema, DropCollectionPropertiesReq, AlterCollectionFieldPropertiesReq, + RefreshLoadReq, isVectorType, } from '../'; @@ -567,6 +568,28 @@ export class Collection extends Database { return promise; } + /** + * Refresh the loading status of a collection. + * + * @param {RefreshLoadReq} data - The request parameters. + * @param {string} data.collection_name - The name of the collection to refresh. + * @param {string} [data.db_name] - The name of the database where the collection is located. + * @param {number} [data.timeout] - An optional duration of time in milliseconds to allow for the RPC. If it is set to undefined, the client keeps waiting until the server responds or error occurs. Default is undefined. + * + * @returns {Promise} The response status of the operation. + * @returns {string} status.error_code - The error code of the operation. + * @returns {string} status.reason - The reason for the error, if any. + * + * @example + * ``` + * const milvusClient = new milvusClient(MILUVS_ADDRESS); + * const resStatus = await milvusClient.refreshLoad({ collection_name: 'my_collection' }); + * ``` + */ + async refreshLoad(data: RefreshLoadReq): Promise { + return this.loadCollectionAsync({...data, refresh: true}); + } + /** * Same function as loadCollection, but it's a synchronous function. * Helps to ensure this collection is loaded. diff --git a/milvus/types/Collection.ts b/milvus/types/Collection.ts index 06a64daa..a26c024b 100644 --- a/milvus/types/Collection.ts +++ b/milvus/types/Collection.ts @@ -151,6 +151,7 @@ export interface LoadCollectionReq extends collectionNameReq { load_fields?: string[]; // optional, load fields skip_load_dynamic_field?: boolean; // optional, skip load dynamic field, default is false } +export interface RefreshLoadReq extends collectionNameReq {} export interface ReleaseLoadCollectionReq extends collectionNameReq {} export interface DropCollectionReq extends collectionNameReq {} diff --git a/test/grpc/Collection.spec.ts b/test/grpc/Collection.spec.ts index 9a46bcc7..5486153a 100644 --- a/test/grpc/Collection.spec.ts +++ b/test/grpc/Collection.spec.ts @@ -510,6 +510,14 @@ describe(`Collection API`, () => { expect(typeof res.progress).toEqual('string'); // int64 in node is string }); + it(`refresh load on LOAD_COLLECTION_NAME_SYNC c should success`, async () => { + const res = await milvusClient.refreshLoad({ + collection_name: LOAD_COLLECTION_NAME_SYNC, + db_name: 'Collection', + }); + expect(res.error_code).toEqual(ErrorCode.SUCCESS); + }); + it(`Get load state throw COLLECTION_NAME_IS_REQUIRED`, async () => { try { await milvusClient.getLoadState({} as any);