@ejfdelgado/ejflab-back 1.20.3 → 1.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/srv/MilvusSrv.mjs +30 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-back",
3
- "version": "1.20.3",
3
+ "version": "1.20.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ejfdelgado/ejflab-back.git"
package/srv/MilvusSrv.mjs CHANGED
@@ -4,6 +4,7 @@ import { encode, decode } from "@msgpack/msgpack";
4
4
  import { General } from "./common/General.mjs";
5
5
  import { CommandMilvus } from "@ejfdelgado/ejflab-common/src/flowchart/steps/CommandMilvus.js";
6
6
  import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
7
+ import { MyError } from "./MyError.mjs";
7
8
 
8
9
  export class MilvusSrv {
9
10
  // MilvusSrv.checkErrors(res);
@@ -282,35 +283,50 @@ export class MilvusSrv {
282
283
  const buffer = req.body;
283
284
  const decoded = decode(buffer);
284
285
  // Connect to database
285
- const {
286
+ let {
286
287
  db_name,
287
288
  collection_name,
288
289
  embeed,
289
- paging
290
+ paging,
291
+ search_params,
292
+ output_fields,
293
+ consistency_level,
290
294
  } = decoded;
291
295
  console.log(`Using database ${db_name}`);
292
296
  await MilvusSrv.useDatabase(client, db_name, false);
293
- const search_params = {
294
- "metric_type": "IP",
295
- "topk": paging['limit'],
296
- "params": JSON.stringify({ nprobe: 1024 }),
297
- };
298
- const results = await client.search({
297
+ if (!search_params) {
298
+ search_params = {
299
+ "metric_type": "IP",
300
+ "topk": paging['limit'],// here is redundant!
301
+ "params": JSON.stringify({ nprobe: 1024 }),
302
+ };
303
+ }
304
+ if (!output_fields) {
305
+ output_fields = ['id', 'document_id', 'face_path', 'millis', 'x1', 'y1', 'x2', 'y2', 'ref_id'];
306
+ }
307
+ if (!consistency_level) {
308
+ consistency_level = "Strong";
309
+ }
310
+ const searchPayload = {
299
311
  collection_name: collection_name,
300
- data: [embeed],
312
+ data: [embeed],//??
301
313
  limit: paging['limit'],
302
314
  offset: paging['offset'],
303
- consistency_level: "Strong",
315
+ consistency_level: consistency_level,
304
316
  search_params: search_params,
305
- output_fields: ['id', 'document_id', 'face_path', 'millis', 'x1', 'y1', 'x2', 'y2', 'ref_id']
306
- });
307
- response.results = results.results.map((entity) => {
317
+ output_fields: output_fields
318
+ };
319
+ const results = await client.search(searchPayload);
320
+ if (results.status.code != 0) {
321
+ throw new MyError(results.status.error_code+". "+results.status.reason)
322
+ }
323
+ response.results = [results.results.map((entity) => {
308
324
  return {
309
325
  id: entity.id,
310
326
  distance: 0,
311
327
  entity
312
328
  };
313
- });
329
+ })];
314
330
  } catch (err) {
315
331
  console.log(err);
316
332
  code = 500;