@@ -13,14 +13,11 @@ import {
13
13
SearchNearVideoArgs ,
14
14
} from '../../grpc/searcher.js' ;
15
15
import { Filters , Filters_Operator } from '../../proto/v1/base.js' ;
16
- import { GenerativeSearch } from '../../proto/v1/generative.js' ;
17
16
import {
18
17
BM25 ,
19
18
CombinationMethod ,
20
- GroupBy ,
21
19
Hybrid ,
22
20
Hybrid_FusionType ,
23
- MetadataRequest ,
24
21
NearAudioSearch ,
25
22
NearDepthSearch ,
26
23
NearIMUSearch ,
@@ -31,9 +28,10 @@ import {
31
28
NearThermalSearch ,
32
29
NearVector ,
33
30
NearVideoSearch ,
34
- PropertiesRequest ,
35
31
Targets ,
36
- } from '../../proto/v1/search_get.js' ;
32
+ } from '../../proto/v1/base_search.js' ;
33
+ import { GenerativeSearch } from '../../proto/v1/generative.js' ;
34
+ import { GroupBy , MetadataRequest , PropertiesRequest } from '../../proto/v1/search_get.js' ;
37
35
import { Filters as FiltersFactory } from '../filters/classes.js' ;
38
36
import filter from '../filters/index.js' ;
39
37
import { TargetVectorInputType } from '../query/types.js' ;
@@ -45,7 +43,7 @@ import { DataGuards, Serialize } from './index.js';
45
43
46
44
describe ( 'Unit testing of Serialize' , ( ) => {
47
45
it ( 'should parse args for fetchObjects' , ( ) => {
48
- const args = Serialize . fetchObjects ( {
46
+ const args = Serialize . search . fetchObjects ( {
49
47
limit : 1 ,
50
48
offset : 0 ,
51
49
after : 'one' ,
@@ -95,7 +93,7 @@ describe('Unit testing of Serialize', () => {
95
93
} ) ;
96
94
97
95
it ( 'should parse args for fetchObjectById' , ( ) => {
98
- const args = Serialize . fetchObjectById ( {
96
+ const args = Serialize . search . fetchObjectById ( {
99
97
id : '1' ,
100
98
includeVector : [ 'title' ] ,
101
99
returnProperties : [ 'name' ] ,
@@ -131,8 +129,7 @@ describe('Unit testing of Serialize', () => {
131
129
} ) ;
132
130
133
131
it ( 'should parse args for bm25' , ( ) => {
134
- const args = Serialize . bm25 ( {
135
- query : 'test' ,
132
+ const args = Serialize . search . bm25 ( 'test' , {
136
133
queryProperties : [ 'name' ] ,
137
134
autoLimit : 1 ,
138
135
} ) ;
@@ -147,18 +144,22 @@ describe('Unit testing of Serialize', () => {
147
144
} ) ;
148
145
149
146
it ( 'should parse args for simple hybrid' , ( ) => {
150
- const args = Serialize . hybrid ( {
151
- query : 'test' ,
152
- queryProperties : [ 'name' ] ,
153
- alpha : 0.6 ,
154
- vector : [ 1 , 2 , 3 ] ,
155
- targetVector : 'title' ,
156
- fusionType : 'Ranked' ,
157
- maxVectorDistance : 0.4 ,
158
- supportsTargets : false ,
159
- supportsVectorsForTargets : false ,
160
- supportsWeightsForTargets : false ,
161
- } ) ;
147
+ const args = Serialize . search . hybrid (
148
+ {
149
+ query : 'test' ,
150
+ supportsTargets : false ,
151
+ supportsVectorsForTargets : false ,
152
+ supportsWeightsForTargets : false ,
153
+ } ,
154
+ {
155
+ queryProperties : [ 'name' ] ,
156
+ alpha : 0.6 ,
157
+ vector : [ 1 , 2 , 3 ] ,
158
+ targetVector : 'title' ,
159
+ fusionType : 'Ranked' ,
160
+ maxVectorDistance : 0.4 ,
161
+ }
162
+ ) ;
162
163
expect ( args ) . toEqual < SearchHybridArgs > ( {
163
164
hybridSearch : Hybrid . fromPartial ( {
164
165
query : 'test' ,
@@ -174,23 +175,27 @@ describe('Unit testing of Serialize', () => {
174
175
} ) ;
175
176
176
177
it ( 'should parse args for multi-vector & multi-target hybrid' , ( ) => {
177
- const args = Serialize . hybrid ( {
178
- query : 'test' ,
179
- queryProperties : [ 'name' ] ,
180
- alpha : 0.6 ,
181
- vector : {
182
- title : [
183
- [ 1 , 2 , 3 ] ,
184
- [ 4 , 5 , 6 ] ,
185
- ] ,
186
- description : [ 7 , 8 , 9 ] ,
178
+ const args = Serialize . search . hybrid (
179
+ {
180
+ query : 'test' ,
181
+ supportsTargets : true ,
182
+ supportsVectorsForTargets : true ,
183
+ supportsWeightsForTargets : true ,
187
184
} ,
188
- targetVector : multiTargetVector ( ) . manualWeights ( { title : [ 0.5 , 0.5 ] , description : 0.5 } ) ,
189
- fusionType : 'Ranked' ,
190
- supportsTargets : true ,
191
- supportsVectorsForTargets : true ,
192
- supportsWeightsForTargets : true ,
193
- } ) ;
185
+ {
186
+ queryProperties : [ 'name' ] ,
187
+ alpha : 0.6 ,
188
+ vector : {
189
+ title : [
190
+ [ 1 , 2 , 3 ] ,
191
+ [ 4 , 5 , 6 ] ,
192
+ ] ,
193
+ description : [ 7 , 8 , 9 ] ,
194
+ } ,
195
+ targetVector : multiTargetVector ( ) . manualWeights ( { title : [ 0.5 , 0.5 ] , description : 0.5 } ) ,
196
+ fusionType : 'Ranked' ,
197
+ }
198
+ ) ;
194
199
expect ( args ) . toEqual < SearchHybridArgs > ( {
195
200
hybridSearch : Hybrid . fromPartial ( {
196
201
query : 'test' ,
@@ -228,14 +233,18 @@ describe('Unit testing of Serialize', () => {
228
233
} ) ;
229
234
230
235
it ( 'should parse args for nearAudio' , ( ) => {
231
- const args = Serialize . nearAudio ( {
232
- audio : 'audio' ,
233
- certainty : 0.6 ,
234
- distance : 0.4 ,
235
- targetVector : 'audio' ,
236
- supportsTargets : false ,
237
- supportsWeightsForTargets : false ,
238
- } ) ;
236
+ const args = Serialize . search . nearAudio (
237
+ {
238
+ audio : 'audio' ,
239
+ supportsTargets : false ,
240
+ supportsWeightsForTargets : false ,
241
+ } ,
242
+ {
243
+ certainty : 0.6 ,
244
+ distance : 0.4 ,
245
+ targetVector : 'audio' ,
246
+ }
247
+ ) ;
239
248
expect ( args ) . toEqual < SearchNearAudioArgs > ( {
240
249
nearAudio : NearAudioSearch . fromPartial ( {
241
250
audio : 'audio' ,
@@ -248,7 +257,7 @@ describe('Unit testing of Serialize', () => {
248
257
} ) ;
249
258
250
259
it ( 'should parse args for nearDepth' , ( ) => {
251
- const args = Serialize . nearDepth ( {
260
+ const args = Serialize . search . nearDepth ( {
252
261
depth : 'depth' ,
253
262
supportsTargets : false ,
254
263
supportsWeightsForTargets : false ,
@@ -262,7 +271,7 @@ describe('Unit testing of Serialize', () => {
262
271
} ) ;
263
272
264
273
it ( 'should parse args for nearIMU' , ( ) => {
265
- const args = Serialize . nearIMU ( {
274
+ const args = Serialize . search . nearIMU ( {
266
275
imu : 'imu' ,
267
276
supportsTargets : false ,
268
277
supportsWeightsForTargets : false ,
@@ -276,7 +285,7 @@ describe('Unit testing of Serialize', () => {
276
285
} ) ;
277
286
278
287
it ( 'should parse args for nearImage' , ( ) => {
279
- const args = Serialize . nearImage ( {
288
+ const args = Serialize . search . nearImage ( {
280
289
image : 'image' ,
281
290
supportsTargets : false ,
282
291
supportsWeightsForTargets : false ,
@@ -290,7 +299,7 @@ describe('Unit testing of Serialize', () => {
290
299
} ) ;
291
300
292
301
it ( 'should parse args for nearObject' , ( ) => {
293
- const args = Serialize . nearObject ( {
302
+ const args = Serialize . search . nearObject ( {
294
303
id : 'id' ,
295
304
supportsTargets : false ,
296
305
supportsWeightsForTargets : false ,
@@ -304,21 +313,25 @@ describe('Unit testing of Serialize', () => {
304
313
} ) ;
305
314
306
315
it ( 'should parse args for nearText' , ( ) => {
307
- const args = Serialize . nearText ( {
308
- query : 'test' ,
309
- moveAway : {
310
- objects : [ '0' ] ,
311
- concepts : [ 'bad' ] ,
312
- force : 0.4 ,
313
- } ,
314
- moveTo : {
315
- objects : [ '1' ] ,
316
- concepts : [ 'good' ] ,
317
- force : 0.6 ,
316
+ const args = Serialize . search . nearText (
317
+ {
318
+ query : 'test' ,
319
+ supportsTargets : false ,
320
+ supportsWeightsForTargets : false ,
318
321
} ,
319
- supportsTargets : false ,
320
- supportsWeightsForTargets : false ,
321
- } ) ;
322
+ {
323
+ moveAway : {
324
+ objects : [ '0' ] ,
325
+ concepts : [ 'bad' ] ,
326
+ force : 0.4 ,
327
+ } ,
328
+ moveTo : {
329
+ objects : [ '1' ] ,
330
+ concepts : [ 'good' ] ,
331
+ force : 0.6 ,
332
+ } ,
333
+ }
334
+ ) ;
322
335
expect ( args ) . toEqual < SearchNearTextArgs > ( {
323
336
nearText : NearTextSearch . fromPartial ( {
324
337
query : [ 'test' ] ,
@@ -338,7 +351,7 @@ describe('Unit testing of Serialize', () => {
338
351
} ) ;
339
352
340
353
it ( 'should parse args for nearThermal' , ( ) => {
341
- const args = Serialize . nearThermal ( {
354
+ const args = Serialize . search . nearThermal ( {
342
355
thermal : 'thermal' ,
343
356
supportsTargets : false ,
344
357
supportsWeightsForTargets : false ,
@@ -352,7 +365,7 @@ describe('Unit testing of Serialize', () => {
352
365
} ) ;
353
366
354
367
it ( 'should parse args for nearVector with single vector' , ( ) => {
355
- const args = Serialize . nearVector ( {
368
+ const args = Serialize . search . nearVector ( {
356
369
vector : [ 1 , 2 , 3 ] ,
357
370
supportsTargets : false ,
358
371
supportsVectorsForTargets : false ,
@@ -367,7 +380,7 @@ describe('Unit testing of Serialize', () => {
367
380
} ) ;
368
381
369
382
it ( 'should parse args for nearVector with two named vectors and supportsTargets (<1.27.0)' , ( ) => {
370
- const args = Serialize . nearVector ( {
383
+ const args = Serialize . search . nearVector ( {
371
384
vector : {
372
385
a : [ 1 , 2 , 3 ] ,
373
386
b : [ 4 , 5 , 6 ] ,
@@ -389,7 +402,7 @@ describe('Unit testing of Serialize', () => {
389
402
} ) ;
390
403
391
404
it ( 'should parse args for nearVector with two named vectors and all supports (==1.27.x)' , ( ) => {
392
- const args = Serialize . nearVector ( {
405
+ const args = Serialize . search . nearVector ( {
393
406
vector : {
394
407
a : [
395
408
[ 1 , 2 , 3 ] ,
@@ -415,7 +428,7 @@ describe('Unit testing of Serialize', () => {
415
428
} ) ;
416
429
417
430
it ( 'should parse args for nearVideo' , ( ) => {
418
- const args = Serialize . nearVideo ( {
431
+ const args = Serialize . search . nearVideo ( {
419
432
video : 'video' ,
420
433
supportsTargets : false ,
421
434
supportsWeightsForTargets : false ,
@@ -444,7 +457,7 @@ describe('Unit testing of Serialize', () => {
444
457
} ) ;
445
458
446
459
it ( 'should parse args for groupBy' , ( ) => {
447
- const args = Serialize . groupBy ( {
460
+ const args = Serialize . search . groupBy ( {
448
461
property : 'name' ,
449
462
numberOfGroups : 1 ,
450
463
objectsPerGroup : 2 ,
@@ -457,14 +470,14 @@ describe('Unit testing of Serialize', () => {
457
470
} ) ;
458
471
459
472
it ( 'should parse args for isGroupBy' , ( ) => {
460
- const isGroupBy = Serialize . isGroupBy ( {
473
+ const isGroupBy = Serialize . search . isGroupBy ( {
461
474
groupBy : {
462
475
property : 'name' ,
463
476
numberOfGroups : 1 ,
464
477
objectsPerGroup : 2 ,
465
478
} ,
466
479
} ) ;
467
- const isNotGroupBy = Serialize . isGroupBy ( { } ) ;
480
+ const isNotGroupBy = Serialize . search . isGroupBy ( { } ) ;
468
481
expect ( isGroupBy ) . toEqual ( true ) ;
469
482
expect ( isNotGroupBy ) . toEqual ( false ) ;
470
483
} ) ;
0 commit comments