Skip to content

Commit

Permalink
add 2.4 index (#272)
Browse files Browse the repository at this point in the history
* add INVERTED index

Signed-off-by: ryjiang <jiangruiyi@gmail.com>

* add GPU_BRUTE_FORCE and GPU_CAGRA

Signed-off-by: ryjiang <jiangruiyi@gmail.com>

* fix index test

Signed-off-by: ryjiang <jiangruiyi@gmail.com>

---------

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
  • Loading branch information
shanghaikid committed Jan 30, 2024
1 parent f2c866c commit 26acea8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
3 changes: 3 additions & 0 deletions milvus/const/milvus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,15 @@ 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',
// scalar
STL_SORT = 'STL_SORT',
TRIE = 'Trie',
INVERTED = 'INVERTED',
}

// MsgType
Expand Down
52 changes: 43 additions & 9 deletions test/grpc/Index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});

Expand All @@ -240,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);
});

Expand Down Expand Up @@ -283,13 +316,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({
Expand Down

0 comments on commit 26acea8

Please sign in to comment.