Skip to content

Commit

Permalink
Add alterCollectionFieldProperties API
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid committed Dec 23, 2024
1 parent e27f658 commit 0821e14
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion milvus/types/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export type TypeParamKey =
| 'max_capacity'
| 'analyzer_params'
| 'enable_analyzer'
| 'enable_match';
| 'enable_match'
| 'mmap.enabled';

// returned from milvus
export type FieldSchema = {
Expand Down
1 change: 1 addition & 0 deletions milvus/utils/Format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const assignTypeParams = (
'enable_match',
'enable_analyzer',
'analyzer_params',
'mmap.enabled',
]
): FieldType => {
const newField = cloneObj<FieldType>(field);
Expand Down
28 changes: 26 additions & 2 deletions test/grpc/Collection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../tools';
import { timeoutTest } from '../tools';

const milvusClient = new MilvusClient({ address: IP, logLevel: 'debug' });
const milvusClient = new MilvusClient({ address: IP, logLevel: 'info' });
const COLLECTION_NAME = GENERATE_NAME();
const NUMBER_DIM_COLLECTION_NAME = GENERATE_NAME();
const NEW_COLLECTION_NAME = GENERATE_NAME();
Expand Down Expand Up @@ -444,6 +444,7 @@ describe(`Collection API`, () => {
collection_name: LOAD_COLLECTION_NAME,
field_name: 'json',
properties: { [key]: value },
db_name: 'Collection', // pass test case
});

expect(alter.error_code).toEqual(ErrorCode.SUCCESS);
Expand All @@ -452,7 +453,30 @@ describe(`Collection API`, () => {
collection_name: LOAD_COLLECTION_NAME,
});

console.dir(describe, { depth: null });
// find json field
const jsonField = describe.schema.fields.find(
f => f.name === 'json'
) as any;
expect(jsonField['mmap.enabled']).toEqual('true');

const alter2 = await milvusClient.alterCollectionFieldProperties({
collection_name: LOAD_COLLECTION_NAME,
field_name: 'varChar',
properties: { max_length: 1024 },
db_name: 'Collection', // pass test case
});
expect(alter2.error_code).toEqual(ErrorCode.SUCCESS);

const describe2 = await milvusClient.describeCollection({
collection_name: LOAD_COLLECTION_NAME,
});

// find varChar field
const varCharField = describe2.schema.fields.find(
f => f.name === 'varChar'
) as any;

expect(varCharField['max_length']).toEqual('1024');
});

it(`Load Collection Sync throw COLLECTION_NAME_IS_REQUIRED`, async () => {
Expand Down
2 changes: 2 additions & 0 deletions test/utils/Format.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ describe('utils/format', () => {
enable_match: true,
analyzer_params: { key: 'value' },
enable_analyzer: true,
'mmap.enabled': true,
} as FieldType;
const expectedOutput = {
name: 'vector',
Expand All @@ -201,6 +202,7 @@ describe('utils/format', () => {
enable_match: 'true',
analyzer_params: JSON.stringify({ key: 'value' }),
enable_analyzer: 'true',
'mmap.enabled': 'true',
},
};
expect(assignTypeParams(field)).toEqual(expectedOutput);
Expand Down

0 comments on commit 0821e14

Please sign in to comment.