@zilliz/milvus2-sdk-node 2.5.0 → 2.5.2

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.
@@ -1,24 +1,5 @@
1
1
  import { ResStatus, KeyValuePair, GrpcTimeOut, TimeStamp, TimeStampArray, resStatusResponse, collectionNameReq } from './Common';
2
2
  import { CompactionState, DataType, LoadState, DataTypeMap, ShowCollectionsType, FunctionType } from '../';
3
- export interface FieldSchema {
4
- type_params: KeyValuePair[];
5
- index_params: KeyValuePair[];
6
- fieldID: string | number;
7
- name: string;
8
- is_primary_key: boolean;
9
- description: string;
10
- data_type: keyof typeof DataType;
11
- autoID: boolean;
12
- state: string;
13
- element_type?: keyof typeof DataType;
14
- default_value?: number | string;
15
- dataType: DataType;
16
- is_partition_key?: boolean;
17
- is_dynamic?: boolean;
18
- is_clustering_key?: boolean;
19
- nullable?: boolean;
20
- is_function_output: boolean;
21
- }
22
3
  export interface CollectionData {
23
4
  name: string;
24
5
  id: string;
@@ -38,9 +19,28 @@ export interface ReplicaInfo {
38
19
  shard_replicas: ShardReplica[];
39
20
  node_ids: string[];
40
21
  }
41
- export type TypeParam = string | number | Record<string, any>;
42
- export type TypeParamKey = 'dim' | 'max_length' | 'max_capacity';
43
- export interface FieldType {
22
+ export type TypeParam = string | number | boolean | Record<string, any>;
23
+ export type TypeParamKey = 'dim' | 'max_length' | 'max_capacity' | 'analyzer_params' | 'enable_analyzer' | 'enable_match';
24
+ export type FieldSchema = {
25
+ type_params: KeyValuePair<TypeParamKey, TypeParam>[];
26
+ index_params: KeyValuePair[];
27
+ fieldID: string | number;
28
+ name: string;
29
+ is_primary_key: boolean;
30
+ description: string;
31
+ data_type: keyof typeof DataType;
32
+ autoID: boolean;
33
+ state: string;
34
+ element_type?: keyof typeof DataType;
35
+ default_value?: number | string;
36
+ dataType: DataType;
37
+ is_partition_key?: boolean;
38
+ is_dynamic?: boolean;
39
+ is_clustering_key?: boolean;
40
+ nullable?: boolean;
41
+ is_function_output: boolean;
42
+ } & Partial<Record<TypeParamKey, TypeParam>>;
43
+ export type FieldType = {
44
44
  name: string;
45
45
  description?: string;
46
46
  data_type: DataType | keyof typeof DataTypeMap;
@@ -49,26 +49,18 @@ export interface FieldType {
49
49
  is_partition_key?: boolean;
50
50
  is_function_output?: boolean;
51
51
  is_clustering_key?: boolean;
52
- type_params?: {
53
- [key: string]: TypeParam;
54
- };
52
+ type_params?: Partial<Record<TypeParamKey, TypeParam>>;
55
53
  autoID?: boolean;
56
- dim?: TypeParam;
57
- max_capacity?: TypeParam;
58
- max_length?: TypeParam;
59
54
  default_value?: number | string;
60
55
  nullable?: boolean;
61
- enable_match?: boolean;
62
- tokenizer_params?: Record<string, any>;
63
- enable_analyzer?: boolean;
64
- }
56
+ } & Partial<Record<TypeParamKey, TypeParam>>;
65
57
  export interface ShowCollectionsReq extends GrpcTimeOut {
66
58
  type?: ShowCollectionsType;
67
59
  collection_names?: string[];
68
60
  db_name?: string;
69
61
  }
70
62
  export type Properties = Record<string, string | number | boolean>;
71
- export type Function = {
63
+ export type FunctionObject = {
72
64
  name: string;
73
65
  description?: string;
74
66
  type: FunctionType;
@@ -88,7 +80,7 @@ export interface BaseCreateCollectionReq extends GrpcTimeOut {
88
80
  enableDynamicField?: boolean;
89
81
  properties?: Properties;
90
82
  db_name?: string;
91
- functions?: Function[];
83
+ functions?: FunctionObject[];
92
84
  }
93
85
  export interface CreateCollectionWithFieldsReq extends BaseCreateCollectionReq {
94
86
  fields: FieldType[];
@@ -157,7 +149,7 @@ export interface CollectionSchema {
157
149
  enable_dynamic_field: boolean;
158
150
  autoID: boolean;
159
151
  fields: FieldSchema[];
160
- functions: Function[];
152
+ functions: FunctionObject[];
161
153
  }
162
154
  export interface DescribeCollectionResponse extends TimeStamp {
163
155
  status: ResStatus;
@@ -175,7 +167,7 @@ export interface DescribeCollectionResponse extends TimeStamp {
175
167
  shards_num: number;
176
168
  num_partitions?: string;
177
169
  db_name: string;
178
- functions: Function[];
170
+ functions: FunctionObject[];
179
171
  }
180
172
  export interface GetCompactionPlansResponse extends resStatusResponse {
181
173
  state: CompactionState;
@@ -216,6 +208,10 @@ export interface GetLoadStateResponse extends resStatusResponse {
216
208
  }
217
209
  export interface AlterCollectionReq extends collectionNameReq {
218
210
  properties: Properties;
211
+ delete_keys?: string[];
212
+ }
213
+ export interface DropCollectionPropertiesReq extends collectionNameReq {
214
+ properties: string[];
219
215
  }
220
216
  export interface DescribeAliasResponse extends resStatusResponse {
221
217
  db_name: string;
@@ -4,9 +4,9 @@ export interface MsgBase {
4
4
  msg_type: MsgType;
5
5
  };
6
6
  }
7
- export interface KeyValuePair {
8
- key: string;
9
- value: string | number;
7
+ export interface KeyValuePair<T = string, U = string | number> {
8
+ key: T;
9
+ value: U;
10
10
  }
11
11
  interface NumberArray {
12
12
  data: Number[];
@@ -40,7 +40,7 @@ export interface TimeStampArray {
40
40
  created_timestamps: string[];
41
41
  created_utc_timestamps: string[];
42
42
  }
43
- export type keyValueObj = Record<string, string | number | string[] | number[] | boolean>;
43
+ export type keyValueObj = Record<string, string | number | string[] | number[] | boolean | unknown>;
44
44
  export interface collectionNameReq extends GrpcTimeOut {
45
45
  collection_name: string;
46
46
  db_name?: string;
@@ -30,7 +30,7 @@ export type JSON = {
30
30
  [key: string]: any;
31
31
  };
32
32
  export type Array = Int8[] | Int16[] | Int32[] | Int64[] | Float[] | Double[] | VarChar[];
33
- export type FieldData = Bool | Int8 | Int16 | Int32 | Int64 | Float | Double | VarChar | JSON | Array | VectorTypes | null;
33
+ export type FieldData = Bool | Int8 | Int16 | Int32 | Int64 | Float | Double | VarChar | JSON | Array | VectorTypes | null | undefined;
34
34
  export interface RowData {
35
35
  [x: string]: FieldData;
36
36
  }
@@ -54,21 +54,32 @@ export type InsertTransformers = {
54
54
  [DataType.BFloat16Vector]?: (bf16: BFloat16Vector) => Buffer;
55
55
  [DataType.Float16Vector]?: (f16: Float16Vector) => Buffer;
56
56
  };
57
- export interface InsertReq extends collectionNameReq {
57
+ interface BaseInsertReq extends collectionNameReq {
58
58
  partition_name?: string;
59
- data?: RowData[];
60
- fields_data?: RowData[];
61
- hash_keys?: Number[];
59
+ hash_keys?: number[];
62
60
  transformers?: InsertTransformers;
63
61
  }
62
+ interface DataInsertReq extends BaseInsertReq {
63
+ data: RowData[];
64
+ fields_data?: never;
65
+ }
66
+ interface FieldsDataInsertReq extends BaseInsertReq {
67
+ fields_data: RowData[];
68
+ data?: never;
69
+ }
70
+ export type InsertReq = DataInsertReq | FieldsDataInsertReq;
64
71
  interface BaseDeleteReq extends collectionNameReq {
65
72
  partition_name?: string;
66
73
  consistency_level?: 'Strong' | 'Session' | 'Bounded' | 'Eventually' | 'Customized';
74
+ exprValues?: keyValueObj;
67
75
  }
68
- export interface DeleteEntitiesReq extends BaseDeleteReq {
69
- filter?: string;
76
+ export type DeleteEntitiesReq = BaseDeleteReq & ({
70
77
  expr?: string;
71
- }
78
+ filter?: never;
79
+ } | {
80
+ filter?: string;
81
+ expr?: never;
82
+ });
72
83
  export interface DeleteByIdsReq extends BaseDeleteReq {
73
84
  ids: string[] | number[];
74
85
  }
@@ -168,6 +179,7 @@ export interface SearchResultData {
168
179
  }
169
180
  export interface SearchResults extends resStatusResponse {
170
181
  results: SearchResultData[];
182
+ recalls: number[];
171
183
  }
172
184
  export interface ImportResponse extends resStatusResponse {
173
185
  tasks: number[];
@@ -201,11 +213,13 @@ export interface SearchParam {
201
213
  group_by_field?: string;
202
214
  group_size?: number;
203
215
  strict_group_size?: boolean;
216
+ hints?: string;
204
217
  }
205
218
  export interface SearchReq extends collectionNameReq {
206
219
  anns_field?: string;
207
220
  partition_names?: string[];
208
221
  expr?: string;
222
+ exprValues?: keyValueObj;
209
223
  search_params: SearchParam;
210
224
  vectors: VectorTypes[];
211
225
  output_fields?: string[];
@@ -236,6 +250,7 @@ export interface SearchSimpleReq extends collectionNameReq {
236
250
  offset?: number;
237
251
  filter?: string;
238
252
  expr?: string;
253
+ exprValues?: keyValueObj;
239
254
  params?: keyValueObj;
240
255
  metric_type?: string;
241
256
  consistency_level?: ConsistencyLevelEnum;
@@ -243,12 +258,14 @@ export interface SearchSimpleReq extends collectionNameReq {
243
258
  group_by_field?: string;
244
259
  group_size?: number;
245
260
  strict_group_size?: boolean;
261
+ hints?: string;
246
262
  round_decimal?: number;
247
263
  transformers?: OutputTransformers;
248
264
  }
249
265
  export type HybridSearchSingleReq = Pick<SearchParam, 'anns_field' | 'ignore_growing' | 'group_by_field'> & {
250
266
  data: SearchDataType;
251
267
  expr?: string;
268
+ exprValues?: keyValueObj;
252
269
  params?: keyValueObj;
253
270
  transformers?: OutputTransformers;
254
271
  };
@@ -256,7 +273,7 @@ export type RerankerObj = {
256
273
  strategy: RANKER_TYPE | string;
257
274
  params: keyValueObj;
258
275
  };
259
- export type HybridSearchReq = Omit<SearchSimpleReq, 'data' | 'vector' | 'vectors' | 'params' | 'anns_field'> & {
276
+ export type HybridSearchReq = Omit<SearchSimpleReq, 'data' | 'vector' | 'vectors' | 'params' | 'anns_field' | 'expr' | 'exprValues'> & {
260
277
  data: HybridSearchSingleReq[];
261
278
  rerank?: RerankerObj;
262
279
  };
@@ -295,6 +312,7 @@ export interface SearchRes extends resStatusResponse {
295
312
  topks: number[];
296
313
  output_fields: string[];
297
314
  group_by_field_value: string;
315
+ recalls: number[];
298
316
  };
299
317
  }
300
318
  export type OutputTransformers = {
@@ -302,7 +320,7 @@ export type OutputTransformers = {
302
320
  [DataType.Float16Vector]?: (f16: Uint8Array) => Float16Vector;
303
321
  [DataType.SparseFloatVector]?: (sparse: SparseVectorDic) => SparseFloatVector;
304
322
  };
305
- export interface QueryReq extends collectionNameReq {
323
+ type BaseQueryReq = collectionNameReq & {
306
324
  output_fields?: string[];
307
325
  partition_names?: string[];
308
326
  ids?: string[] | number[];
@@ -312,7 +330,15 @@ export interface QueryReq extends collectionNameReq {
312
330
  limit?: number;
313
331
  consistency_level?: ConsistencyLevelEnum;
314
332
  transformers?: OutputTransformers;
315
- }
333
+ exprValues?: keyValueObj;
334
+ };
335
+ export type QueryReq = BaseQueryReq & ({
336
+ expr?: string;
337
+ filter?: never;
338
+ } | {
339
+ filter?: string;
340
+ expr?: never;
341
+ });
316
342
  export interface QueryIteratorReq extends Omit<QueryReq, 'ids' | 'offset' | 'limit'> {
317
343
  limit?: number;
318
344
  batchSize: number;
@@ -1 +1 @@
1
- {"version":3,"file":"Data.js","sourceRoot":"","sources":["../../../milvus/types/Data.ts"],"names":[],"mappings":";;AAAA,2BAca"}
1
+ {"version":3,"file":"Data.js","sourceRoot":"","sources":["../../../milvus/types/Data.ts"],"names":[],"mappings":";;AACA,2BAca"}
@@ -25,6 +25,11 @@ export interface AlterDatabaseRequest extends GrpcTimeOut {
25
25
  db_name: string;
26
26
  db_id?: string;
27
27
  properties: Properties;
28
+ delete_keys?: string[];
29
+ }
30
+ export interface DropDatabasePropertiesRequest extends GrpcTimeOut {
31
+ db_name: string;
32
+ properties: string[];
28
33
  }
29
34
  export interface AlterDatabaseResponse extends resStatusResponse {
30
35
  }
@@ -62,3 +62,7 @@ export interface AlterIndexReq extends collectionNameReq {
62
62
  index_name: string;
63
63
  params: Record<string, number | string | boolean>;
64
64
  }
65
+ export interface DropIndexPropertiesReq extends collectionNameReq {
66
+ index_name: string;
67
+ properties: string[];
68
+ }
@@ -1,5 +1,5 @@
1
1
  import { Type, Root } from 'protobufjs';
2
- import { KeyValuePair, FieldType, DataTypeMap, DataType, CreateCollectionReq, DescribeCollectionResponse, RowData, _Field, FieldData, SearchReq, SearchSimpleReq, SearchParam, HybridSearchSingleReq, HybridSearchReq, DslType, SearchRes, ConsistencyLevelEnum, RerankerObj, InsertTransformers, OutputTransformers, SearchDataType, FieldSchema, SearchMultipleDataType } from '../';
2
+ import { KeyValuePair, FieldType, DataTypeMap, DataType, CreateCollectionReq, DescribeCollectionResponse, RowData, _Field, FieldData, SearchReq, SearchSimpleReq, SearchParam, HybridSearchSingleReq, HybridSearchReq, DslType, SearchRes, ConsistencyLevelEnum, RerankerObj, InsertTransformers, OutputTransformers, SearchDataType, FieldSchema, SearchMultipleDataType, TypeParamKey, keyValueObj } from '../';
3
3
  /**
4
4
  * Formats key-value data based on the provided keys.
5
5
  * @param {KeyValuePair[]} data - The array of key-value pairs.
@@ -72,7 +72,7 @@ export declare const formatAddress: (address: string) => string;
72
72
  * @param typeParamKeys - Keys to assign to `type_params` if present in `field`.
73
73
  * @returns The modified `FieldType` object.
74
74
  */
75
- export declare const assignTypeParams: (field: FieldType, typeParamKeys?: string[]) => FieldType;
75
+ export declare const assignTypeParams: (field: FieldType, typeParamKeys?: TypeParamKey[]) => FieldType;
76
76
  /**
77
77
  * Parses a time token and returns the corresponding number of milliseconds.
78
78
  *
@@ -183,6 +183,20 @@ export declare const WeightedRanker: (weights: number[]) => RerankerObj;
183
183
  * @returns The converted rerank parameters object.
184
184
  */
185
185
  export declare const convertRerankParams: (rerank: RerankerObj) => any;
186
+ type FormatedSearchRequest = {
187
+ collection_name: string;
188
+ partition_names: string[];
189
+ output_fields: string[];
190
+ nq?: number;
191
+ dsl?: string;
192
+ dsl_type?: DslType;
193
+ placeholder_group?: Uint8Array;
194
+ search_params?: KeyValuePair[];
195
+ consistency_level: ConsistencyLevelEnum;
196
+ expr?: string;
197
+ expr_template_values?: keyValueObj;
198
+ rank_params?: KeyValuePair[];
199
+ };
186
200
  /**
187
201
  * This method is used to build search request for a given data.
188
202
  * It first fetches the collection info and then constructs the search request based on the data type.
@@ -207,36 +221,10 @@ export declare const convertRerankParams: (rerank: RerankerObj) => any;
207
221
  */
208
222
  export declare const buildSearchRequest: (data: SearchReq | SearchSimpleReq | HybridSearchReq, collectionInfo: DescribeCollectionResponse, milvusProto: Root) => {
209
223
  isHybridSearch: boolean;
210
- request: {
211
- collection_name: string;
212
- partition_names: string[];
213
- output_fields: string[];
214
- nq: number;
215
- dsl: string;
216
- dsl_type: DslType;
217
- placeholder_group: Uint8Array;
218
- search_params: KeyValuePair[];
219
- consistency_level: ConsistencyLevelEnum;
220
- } | {
221
- collection_name: string;
222
- partition_names: string[] | undefined;
223
- requests: {
224
- collection_name: string;
225
- partition_names: string[];
226
- output_fields: string[];
227
- nq: number;
228
- dsl: string;
229
- dsl_type: DslType;
230
- placeholder_group: Uint8Array;
231
- search_params: KeyValuePair[];
232
- consistency_level: ConsistencyLevelEnum;
233
- }[];
234
- rank_params: KeyValuePair[];
235
- output_fields: string[];
236
- consistency_level: ConsistencyLevelEnum;
237
- };
238
- nq: number;
224
+ request: FormatedSearchRequest;
225
+ nq: number | undefined;
239
226
  round_decimal: number;
227
+ expr_template_values: Record<string, TemplateValue> | undefined;
240
228
  };
241
229
  /**
242
230
  * Formats the search results returned by Milvus into row data for easier use.
@@ -259,3 +247,41 @@ export declare const formatSearchResult: (searchRes: SearchRes, options: {
259
247
  * @returns {VectorTypes[]} The formatted search vector or array of vectors.
260
248
  */
261
249
  export declare const formatSearchData: (searchData: SearchDataType | SearchMultipleDataType, field: FieldSchema) => SearchMultipleDataType;
250
+ type TemplateValue = {
251
+ bool_val: boolean;
252
+ } | {
253
+ int64_val: number;
254
+ } | {
255
+ float_val: number;
256
+ } | {
257
+ string_val: string;
258
+ } | {
259
+ array_val: TemplateArrayValue;
260
+ };
261
+ type TemplateArrayValue = {
262
+ bool_data: {
263
+ data: boolean[];
264
+ };
265
+ } | {
266
+ long_data: {
267
+ data: number[];
268
+ };
269
+ } | {
270
+ double_data: {
271
+ data: number[];
272
+ };
273
+ } | {
274
+ string_data: {
275
+ data: string[];
276
+ };
277
+ } | {
278
+ json_data: {
279
+ data: any[];
280
+ };
281
+ } | {
282
+ array_data: {
283
+ data: TemplateArrayValue[];
284
+ };
285
+ };
286
+ export declare const formatExprValues: (exprValues: Record<string, any>) => Record<string, TemplateValue>;
287
+ export {};
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.formatSearchData = exports.formatSearchResult = exports.buildSearchRequest = exports.convertRerankParams = exports.WeightedRanker = exports.RRFRanker = exports.buildSearchParams = exports.buildFieldData = exports.getAuthString = exports.buildFieldDataMap = exports.buildDynamicRow = exports.formatDescribedCol = exports.formatCollectionSchema = exports.cloneObj = exports.convertToDataType = exports.extractMethodName = exports.parseTimeToken = exports.assignTypeParams = exports.formatAddress = exports.stringToBase64 = exports.datetimeToHybrids = exports.unixtimeToHybridts = exports.hybridtsToUnixtime = exports.checkTimeParam = exports.formatNumberPrecision = exports.parseToKeyValue = exports.formatKeyValueData = void 0;
14
+ exports.formatExprValues = exports.formatSearchData = exports.formatSearchResult = exports.buildSearchRequest = exports.convertRerankParams = exports.WeightedRanker = exports.RRFRanker = exports.buildSearchParams = exports.buildFieldData = exports.getAuthString = exports.buildFieldDataMap = exports.buildDynamicRow = exports.formatDescribedCol = exports.formatCollectionSchema = exports.cloneObj = exports.convertToDataType = exports.extractMethodName = exports.parseTimeToken = exports.assignTypeParams = exports.formatAddress = exports.stringToBase64 = exports.datetimeToHybrids = exports.unixtimeToHybridts = exports.hybridtsToUnixtime = exports.checkTimeParam = exports.formatNumberPrecision = exports.parseToKeyValue = exports.formatKeyValueData = void 0;
15
15
  const __1 = require("../");
16
16
  /**
17
17
  * Formats key-value data based on the provided keys.
@@ -304,6 +304,17 @@ const formatDescribedCol = (data) => {
304
304
  // add a dataType property which indicate datatype number
305
305
  (_b = (_a = newData.schema) === null || _a === void 0 ? void 0 : _a.fields) === null || _b === void 0 ? void 0 : _b.forEach(f => {
306
306
  f.dataType = __1.DataTypeMap[f.data_type];
307
+ // if default_value is set, parse it to the correct format
308
+ if (f.default_value) {
309
+ const defaultValue = f.default_value;
310
+ f.default_value = defaultValue[defaultValue.data];
311
+ }
312
+ // extract type params(key value pair = {key: 'xxx', value: any}), and assign it to the field object(key)
313
+ if (f.type_params && f.type_params.length > 0) {
314
+ f.type_params.forEach(keyValuePair => {
315
+ f[keyValuePair.key] = keyValuePair.value;
316
+ });
317
+ }
307
318
  });
308
319
  return newData;
309
320
  };
@@ -490,9 +501,11 @@ const buildFieldData = (rowData, field, transformers) => {
490
501
  : Buffer.alloc(0);
491
502
  case __1.DataType.Array:
492
503
  const elementField = Object.assign(Object.assign({}, field), { type: elementType });
493
- return (0, exports.buildFieldData)(rowData, elementField, transformers);
504
+ return rowData[name] === null
505
+ ? undefined
506
+ : (0, exports.buildFieldData)(rowData, elementField, transformers);
494
507
  default:
495
- return rowData[name];
508
+ return rowData[name] === null ? undefined : rowData[name];
496
509
  }
497
510
  };
498
511
  exports.buildFieldData = buildFieldData;
@@ -522,6 +535,9 @@ const buildSearchParams = (data, anns_field) => {
522
535
  if (data.group_size) {
523
536
  search_params.group_size = data.group_size;
524
537
  }
538
+ if (data.hints) {
539
+ search_params.hints = data.hints;
540
+ }
525
541
  return search_params;
526
542
  };
527
543
  exports.buildSearchParams = buildSearchParams;
@@ -637,17 +653,22 @@ const buildSearchRequest = (data, collectionInfo, milvusProto) => {
637
653
  // format searching data
638
654
  searchData = (0, exports.formatSearchData)(searchData, field);
639
655
  // create search request
640
- requests.push({
656
+ const request = {
641
657
  collection_name: req.collection_name,
642
658
  partition_names: req.partition_names || [],
643
659
  output_fields: req.output_fields || default_output_fields,
644
660
  nq: searchReq.nq || searchData.length,
645
- dsl: searchReq.expr || searchSimpleReq.filter || '',
661
+ dsl: req.expr || searchReq.expr || searchSimpleReq.filter || '',
646
662
  dsl_type: __1.DslType.BoolExprV1,
647
663
  placeholder_group: (0, __1.buildPlaceholderGroupBytes)(milvusProto, searchData, field),
648
664
  search_params: (0, exports.parseToKeyValue)(searchReq.search_params || (0, exports.buildSearchParams)(req, name)),
649
665
  consistency_level: req.consistency_level || collectionInfo.consistency_level,
650
- });
666
+ };
667
+ // if exprValues is set, add it to the request(inner)
668
+ if (req.exprValues) {
669
+ request.expr_template_values = (0, exports.formatExprValues)(req.exprValues);
670
+ }
671
+ requests.push(request);
651
672
  }
652
673
  }
653
674
  /**
@@ -657,8 +678,12 @@ const buildSearchRequest = (data, collectionInfo, milvusProto) => {
657
678
  * So the score need to slice by round_decimal
658
679
  */
659
680
  const round_decimal = (_d = (_b = (_a = searchReq.search_params) === null || _a === void 0 ? void 0 : _a.round_decimal) !== null && _b !== void 0 ? _b : (_c = searchSimpleReq.params) === null || _c === void 0 ? void 0 : _c.round_decimal) !== null && _d !== void 0 ? _d : -1;
681
+ // outter expr_template_values
682
+ const expr_template_values = searchSimpleReq.exprValues
683
+ ? (0, exports.formatExprValues)(searchSimpleReq.exprValues)
684
+ : undefined;
660
685
  return {
661
- isHybridSearch,
686
+ isHybridSearch: isHybridSearch,
662
687
  request: isHybridSearch
663
688
  ? {
664
689
  collection_name: data.collection_name,
@@ -678,6 +703,7 @@ const buildSearchRequest = (data, collectionInfo, milvusProto) => {
678
703
  : requests[0],
679
704
  nq: requests[0].nq,
680
705
  round_decimal,
706
+ expr_template_values,
681
707
  };
682
708
  };
683
709
  exports.buildSearchRequest = buildSearchRequest;
@@ -778,4 +804,82 @@ const formatSearchData = (searchData, field) => {
778
804
  }
779
805
  };
780
806
  exports.formatSearchData = formatSearchData;
807
+ const formatExprValues = (exprValues) => {
808
+ const result = {};
809
+ for (const [key, value] of Object.entries(exprValues)) {
810
+ if (Array.isArray(value)) {
811
+ // Handle arrays
812
+ result[key] = { array_val: convertArray(value) };
813
+ }
814
+ else {
815
+ // Handle primitive types
816
+ if (typeof value === 'boolean') {
817
+ result[key] = { bool_val: value };
818
+ }
819
+ else if (typeof value === 'number') {
820
+ result[key] = Number.isInteger(value)
821
+ ? { int64_val: value }
822
+ : { float_val: value };
823
+ }
824
+ else if (typeof value === 'string') {
825
+ result[key] = { string_val: value };
826
+ }
827
+ }
828
+ }
829
+ return result;
830
+ };
831
+ exports.formatExprValues = formatExprValues;
832
+ const convertArray = (arr) => {
833
+ const first = arr[0];
834
+ switch (typeof first) {
835
+ case 'boolean':
836
+ return {
837
+ bool_data: {
838
+ data: arr,
839
+ },
840
+ };
841
+ case 'number':
842
+ if (Number.isInteger(first)) {
843
+ return {
844
+ long_data: {
845
+ data: arr,
846
+ },
847
+ };
848
+ }
849
+ else {
850
+ return {
851
+ double_data: {
852
+ data: arr,
853
+ },
854
+ };
855
+ }
856
+ case 'string':
857
+ return {
858
+ string_data: {
859
+ data: arr,
860
+ },
861
+ };
862
+ case 'object':
863
+ if (Array.isArray(first)) {
864
+ return {
865
+ array_data: {
866
+ data: arr.map(convertArray),
867
+ },
868
+ };
869
+ }
870
+ else {
871
+ return {
872
+ json_data: {
873
+ data: arr,
874
+ },
875
+ };
876
+ }
877
+ default:
878
+ return {
879
+ string_data: {
880
+ data: arr,
881
+ },
882
+ };
883
+ }
884
+ };
781
885
  //# sourceMappingURL=Format.js.map