Skip to content

Commit

Permalink
Update DataQuery.ts (#244)
Browse files Browse the repository at this point in the history
Add delete test
  • Loading branch information
shanghaikid authored Sep 26, 2023
1 parent ab18d53 commit 9ff2f88
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions examples/milvus/DataQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ const COLLECTION_NAME = 'data_query_example';
// create collection
const create = await milvusClient.createCollection({
collection_name: COLLECTION_NAME,
consistency_level: 'Strong',
fields: [
{
name: 'age',
name: 'id',
description: 'ID field',
data_type: DataType.Int64,
is_primary_key: true,
autoID: true,
autoID: false,
},
{
name: 'vector',
Expand Down Expand Up @@ -49,6 +50,7 @@ const COLLECTION_NAME = 'data_query_example';
],
height: 20405,
name: 'zlnmh',
id: 1,
},
{
vector: [
Expand All @@ -58,6 +60,7 @@ const COLLECTION_NAME = 'data_query_example';
],
height: 93773,
name: '5lr9y',
id: 2,
},
{
vector: [
Expand All @@ -67,6 +70,7 @@ const COLLECTION_NAME = 'data_query_example';
],
height: 85122,
name: 'nes0j',
id: 3,
},
{
vector: [
Expand All @@ -76,6 +80,7 @@ const COLLECTION_NAME = 'data_query_example';
],
height: 92037,
name: 'ct2li',
id: 4,
},
{
vector: [
Expand All @@ -85,6 +90,7 @@ const COLLECTION_NAME = 'data_query_example';
],
height: 31400,
name: '6ghrg',
id: 5,
},
{
vector: [
Expand All @@ -94,6 +100,7 @@ const COLLECTION_NAME = 'data_query_example';
],
height: 1778,
name: 'sb7mt',
id: 6,
},
];
const params: InsertReq = {
Expand Down Expand Up @@ -123,13 +130,31 @@ const COLLECTION_NAME = 'data_query_example';
console.time('Query time');
const query = await milvusClient.query({
collection_name: COLLECTION_NAME,
filter: 'height > 31400',
output_fields: ['age', 'height', 'vector'],
filter: 'id > 0',
output_fields: ['id', 'height', 'vector'],
limit: 100,
});
console.timeEnd('Query time');
console.log('query result', query);

// delete data
const del = await milvusClient.delete({
collection_name: COLLECTION_NAME,
ids: [1, 2],
});

console.log('del', del);
// do the query
console.time('Query after del');
const queryAfterDel = await milvusClient.query({
collection_name: COLLECTION_NAME,
filter: 'id > 0',
output_fields: ['id', 'height', 'vector'],
limit: 100,
});
console.timeEnd('Query after time');
console.log('query after del', queryAfterDel);

// drop collection
await milvusClient.dropCollection({
collection_name: COLLECTION_NAME,
Expand Down

0 comments on commit 9ff2f88

Please sign in to comment.