Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid committed Dec 18, 2024
1 parent 6fb5c1f commit 00b774f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
50 changes: 49 additions & 1 deletion milvus/grpc/MilvusIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
GetIndexBuildProgressReq,
GetIndexStateReq,
AlterIndexReq,
DropIndexPropertiesReq,
ResStatus,
DescribeIndexResponse,
GetIndexStateResponse,
Expand Down Expand Up @@ -338,7 +339,7 @@ export class Index extends Data {
* console.log(res);
* ```
*/
async alterIndex(data: AlterIndexReq): Promise<ResStatus> {
async alterIndexProperties(data: AlterIndexReq): Promise<ResStatus> {
checkCollectionName(data);
const req = {
collection_name: data.collection_name,
Expand All @@ -358,4 +359,51 @@ export class Index extends Data {
);
return promise;
}

/**
* @deprecated
*/
alterIndex = this.alterIndexProperties;

/**
* Drop index properties.
* @param {DropIndexPropertiesReq} data - The data for dropping the index properties.
* @param {string} data.collection_name - The name of the collection.
* @param {string} data.index_name - The name of the index.
* @param {string[]} data.properties - The properties to be dropped.
* @param {string} [data.db_name] - The name of the database.
* @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 an error occurs. Default is undefined.
* @returns {Promise<ResStatus>} - A promise that resolves to a response status object.
*
* @example
* ```
* const milvusClient = new MilvusClient(MILUVS_ADDRESS);
* const dropIndexPropertiesReq = {
* collection_name: 'my_collection',
* index_name: 'my_index',
* properties: ['mmap.enabled'],
* };
* const res = await milvusClient.dropIndexProperties(dropIndexPropertiesReq);
* console.log(res);
* ```
*/
async dropIndexProperties(data: DropIndexPropertiesReq): Promise<ResStatus> {
const req = {
collection_name: data.collection_name,
index_name: data.index_name,
delete_keys: data.properties,
} as any;

if (data.db_name) {
req.db_name = data.db_name;
}

const promise = await promisify(
this.channelPool,
'AlterIndex',
req,
data.timeout || this.timeout
);
return promise;
}
}
5 changes: 5 additions & 0 deletions milvus/types/MilvusIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ export interface AlterIndexReq extends collectionNameReq {
index_name: string;
params: Record<string, number | string | boolean>;
}

export interface DropIndexPropertiesReq extends collectionNameReq {
index_name: string;
properties: string[];
}
17 changes: 17 additions & 0 deletions test/grpc/Index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,23 @@ describe(`Milvus Index API`, () => {
// console.log('describe', describe.index_descriptions[0].params);
});

it(`Drop Index properties with field name should be success`, async () => {
const res = await milvusClient.dropIndexProperties({
collection_name: COLLECTION_NAME,
index_name: INDEX_NAME,
properties: ['mmap.enabled'],
});
expect(res.error_code).toEqual(ErrorCode.SUCCESS);

const describe = await milvusClient.describeIndex({
collection_name: COLLECTION_NAME,
index_name: INDEX_NAME,
});

const params = describe.index_descriptions[0].params;
expect(findKeyValue(params, 'mmap.enabled')).toEqual(undefined);
});

// @Deprecated
// it(`Get Index progress with field name should be failed`, async () => {
// const res = await milvusClient.getIndexBuildProgress({
Expand Down

0 comments on commit 00b774f

Please sign in to comment.