Skip to content

Commit

Permalink
fix 12s waiting for the query request (#687)
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid authored Nov 11, 2024
1 parent 0c4363b commit e1051a4
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions server/src/collections/collections.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
DataType,
HybridSearchReq,
SearchSimpleReq,
LoadState,
} from '@zilliz/milvus2-sdk-node';
import { Parser } from '@json2csv/plainjs';
import {
Expand Down Expand Up @@ -246,15 +247,21 @@ export class CollectionsService {
const { milvusClient } = clientCache.get(clientId);
let count = 0;
try {
const countRes = await milvusClient.count(data);
count = countRes.data;
} catch (error) {
const collectionStatisticsRes = await this.getCollectionStatistics(
clientId,
data
);
count = collectionStatisticsRes.data.row_count;
}
// check if the collection is loaded
const loadStateRes = await milvusClient.getLoadState(data);

if (loadStateRes.state === LoadState.LoadStateLoaded) {
const countRes = await milvusClient.count(data);
count = countRes.data;
} else {
const collectionStatisticsRes = await this.getCollectionStatistics(
clientId,
data
);
count = collectionStatisticsRes.data.row_count;
}
} catch (error) {}

return { rowCount: Number(count) } as CountObject;
}

Expand Down

0 comments on commit e1051a4

Please sign in to comment.