diff --git a/milvus/http/Vector.ts b/milvus/http/Vector.ts index a24cc0e6..cd916424 100644 --- a/milvus/http/Vector.ts +++ b/milvus/http/Vector.ts @@ -33,9 +33,9 @@ export function Vector>(Base: T) { async get( params: HttpVectorGetReq, options?: FetchOptions - ): Promise { + ): Promise { const url = `/vector/get`; - return await this.GET(url, params, options); + return await this.POST(url, params, options); } // POST insert data @@ -52,7 +52,7 @@ export function Vector>(Base: T) { data: HttpVectorInsertReq, options?: FetchOptions ): Promise { - const url = `/vector/insert`; + const url = `/vector/upsert`; return await this.POST(url, data, options); } diff --git a/test/http/test.ts b/test/http/test.ts index 28a8c97f..465ca8b5 100644 --- a/test/http/test.ts +++ b/test/http/test.ts @@ -12,7 +12,7 @@ import { } from '../tools'; export function generateTests( - config: HttpClientConfig & { address?: string; cloud?: boolean, desc: string } + config: HttpClientConfig & { address?: string; cloud?: boolean; desc: string } ) { describe(config.desc, () => { if (!config.cloud) { @@ -42,7 +42,7 @@ export function generateTests( dimension: 128, }; - const count = 10; + const count = 100; const data = generateInsertData( [ ...genCollectionParams({ @@ -123,7 +123,18 @@ export function generateTests( expect(insert.data.insertCount).toEqual(count); }); - it('should query data successfully', async () => { + // it('should upsert data successfully', async () => { + // const upsert = await client.upsert({ + // collectionName: createParams.collectionName, + // data: data, + // }); + + // console.log(upsert); + // expect(upsert.code).toEqual(200); + // expect(upsert.data.insertCount).toEqual(count); + // }); + + it('should query data and get data and delete successfully', async () => { const query = await client.query({ collectionName: createParams.collectionName, outputFields: ['id'], @@ -132,6 +143,22 @@ export function generateTests( expect(query.code).toEqual(200); expect(query.data.length).toEqual(data.length); + + const ids = query.data.map(d => d.id); + + const get = await client.get({ + collectionName: createParams.collectionName, + id: ids, + outputFields: ['id', 'vector'], + }); + expect(get.code).toEqual(200); + expect(get.data.length).toEqual(ids.length); + + const del = await client.delete({ + collectionName: createParams.collectionName, + id: ids, + }); + expect(del.code).toEqual(200); }); it('should search data successfully', async () => {