From 41097faf027086e68a73a18ef6263158d92099ce Mon Sep 17 00:00:00 2001 From: ryjiang Date: Wed, 10 Jan 2024 14:39:17 +0800 Subject: [PATCH 1/3] add INVERTED index Signed-off-by: ryjiang --- milvus/const/milvus.ts | 1 + test/grpc/Index.spec.ts | 48 ++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/milvus/const/milvus.ts b/milvus/const/milvus.ts index 5a9bd553..39f12233 100644 --- a/milvus/const/milvus.ts +++ b/milvus/const/milvus.ts @@ -135,6 +135,7 @@ export enum IndexType { // scalar STL_SORT = 'STL_SORT', TRIE = 'Trie', + INVERTED = 'INVERTED', } // MsgType diff --git a/test/grpc/Index.spec.ts b/test/grpc/Index.spec.ts index 7c2129be..3154c83c 100644 --- a/test/grpc/Index.spec.ts +++ b/test/grpc/Index.spec.ts @@ -199,6 +199,36 @@ describe(`Milvus Index API`, () => { expect(res.error_code).toEqual(ErrorCode.SUCCESS); }); + it(`Create STL_SORT index on int64 should success`, async () => { + const res = await milvusClient.createIndex({ + index_name: 'int64_index', + collection_name: COLLECTION_NAME, + field_name: 'int64', + index_type: IndexType.STL_SORT, + }); + expect(res.error_code).toEqual(ErrorCode.SUCCESS); + }); + + it(`Create TRIE index on int64 varchar success`, async () => { + const res = await milvusClient.createIndex({ + index_name: 'varchar_index', + collection_name: COLLECTION_NAME, + field_name: 'varChar', + index_type: IndexType.TRIE, + }); + expect(res.error_code).toEqual(ErrorCode.SUCCESS); + }); + + it(`Create INVERTED index on int64 varchar success`, async () => { + const res = await milvusClient.createIndex({ + index_name: 'float_index', + collection_name: COLLECTION_NAME, + field_name: 'float', + index_type: IndexType.INVERTED, + }); + expect(res.error_code).toEqual(ErrorCode.SUCCESS); + }); + it(`Create Index without name should success`, async () => { const res = await milvusClient.createIndex({ collection_name: COLLECTION_NAME_WITHOUT_INDEX_NAME, @@ -230,7 +260,8 @@ describe(`Milvus Index API`, () => { collection_name: COLLECTION_NAME, index_name: INDEX_NAME, }); - expect(res.index_descriptions[0].index_name).toEqual(INDEX_NAME); + const allIndexNames = res.index_descriptions.map(i => i.index_name); + expect(allIndexNames.includes(INDEX_NAME)).toEqual(true); expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); }); @@ -283,13 +314,14 @@ describe(`Milvus Index API`, () => { expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); }); - it(`Get Index progress with field name should be failed`, async () => { - const res = await milvusClient.getIndexBuildProgress({ - collection_name: COLLECTION_NAME, - field_name: VECTOR_FIELD_NAME, - }); - expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); - }); + // @Deprecated + // it(`Get Index progress with field name should be failed`, async () => { + // const res = await milvusClient.getIndexBuildProgress({ + // collection_name: COLLECTION_NAME, + // field_name: VECTOR_FIELD_NAME, + // }); + // expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); + // }); it(`Drop Index with index name`, async () => { const res = await milvusClient.dropIndex({ From 8d03eaf5e1d1b63ee2bfa307218bf95665c6276c Mon Sep 17 00:00:00 2001 From: ryjiang Date: Wed, 10 Jan 2024 14:58:27 +0800 Subject: [PATCH 2/3] add GPU_BRUTE_FORCE and GPU_CAGRA Signed-off-by: ryjiang --- milvus/const/milvus.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/milvus/const/milvus.ts b/milvus/const/milvus.ts index 39f12233..ba9d3cba 100644 --- a/milvus/const/milvus.ts +++ b/milvus/const/milvus.ts @@ -129,6 +129,8 @@ export enum IndexType { GPU_IVF_FLAT = 'GPU_IVF_FLAT', GPU_IVF_PQ = 'GPU_IVF_PQ', GPU_IVF_SQ8 = 'GPU_IVF_SQ8', + GPU_BRUTE_FORCE = 'GPU_BRUTE_FORCE', + GPU_CAGRA = 'GPU_CAGRA', RAFT_IVF_FLAT = 'RAFT_IVF_FLAT', RAFT_IVF_PQ = 'RAFT_IVF_PQ', ScaNN = 'SCANN', From c65b1d3cd386f99c6f50159a9d05fd0077d0021e Mon Sep 17 00:00:00 2001 From: ryjiang Date: Wed, 10 Jan 2024 15:02:53 +0800 Subject: [PATCH 3/3] fix index test Signed-off-by: ryjiang --- test/grpc/Index.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/grpc/Index.spec.ts b/test/grpc/Index.spec.ts index 3154c83c..78a7c79f 100644 --- a/test/grpc/Index.spec.ts +++ b/test/grpc/Index.spec.ts @@ -271,7 +271,9 @@ describe(`Milvus Index API`, () => { field_name: VECTOR_FIELD_NAME, }); - expect(res.index_descriptions[0].field_name).toEqual(VECTOR_FIELD_NAME); + const field_names = res.index_descriptions.map(i => i.field_name); + expect(field_names.includes(VECTOR_FIELD_NAME)).toEqual(true); + expect(res.status.error_code).toEqual(ErrorCode.SUCCESS); });