@@ -13,14 +13,11 @@ import {
1313 SearchNearVideoArgs ,
1414} from '../../grpc/searcher.js' ;
1515import { Filters , Filters_Operator } from '../../proto/v1/base.js' ;
16- import { GenerativeSearch } from '../../proto/v1/generative.js' ;
1716import {
1817 BM25 ,
1918 CombinationMethod ,
20- GroupBy ,
2119 Hybrid ,
2220 Hybrid_FusionType ,
23- MetadataRequest ,
2421 NearAudioSearch ,
2522 NearDepthSearch ,
2623 NearIMUSearch ,
@@ -31,9 +28,10 @@ import {
3128 NearThermalSearch ,
3229 NearVector ,
3330 NearVideoSearch ,
34- PropertiesRequest ,
3531 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' ;
3735import { Filters as FiltersFactory } from '../filters/classes.js' ;
3836import filter from '../filters/index.js' ;
3937import { TargetVectorInputType } from '../query/types.js' ;
@@ -45,7 +43,7 @@ import { DataGuards, Serialize } from './index.js';
4543
4644describe ( 'Unit testing of Serialize' , ( ) => {
4745 it ( 'should parse args for fetchObjects' , ( ) => {
48- const args = Serialize . fetchObjects ( {
46+ const args = Serialize . search . fetchObjects ( {
4947 limit : 1 ,
5048 offset : 0 ,
5149 after : 'one' ,
@@ -95,7 +93,7 @@ describe('Unit testing of Serialize', () => {
9593 } ) ;
9694
9795 it ( 'should parse args for fetchObjectById' , ( ) => {
98- const args = Serialize . fetchObjectById ( {
96+ const args = Serialize . search . fetchObjectById ( {
9997 id : '1' ,
10098 includeVector : [ 'title' ] ,
10199 returnProperties : [ 'name' ] ,
@@ -131,8 +129,7 @@ describe('Unit testing of Serialize', () => {
131129 } ) ;
132130
133131 it ( 'should parse args for bm25' , ( ) => {
134- const args = Serialize . bm25 ( {
135- query : 'test' ,
132+ const args = Serialize . search . bm25 ( 'test' , {
136133 queryProperties : [ 'name' ] ,
137134 autoLimit : 1 ,
138135 } ) ;
@@ -147,18 +144,22 @@ describe('Unit testing of Serialize', () => {
147144 } ) ;
148145
149146 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+ ) ;
162163 expect ( args ) . toEqual < SearchHybridArgs > ( {
163164 hybridSearch : Hybrid . fromPartial ( {
164165 query : 'test' ,
@@ -174,23 +175,27 @@ describe('Unit testing of Serialize', () => {
174175 } ) ;
175176
176177 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 ,
187184 } ,
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+ ) ;
194199 expect ( args ) . toEqual < SearchHybridArgs > ( {
195200 hybridSearch : Hybrid . fromPartial ( {
196201 query : 'test' ,
@@ -228,14 +233,18 @@ describe('Unit testing of Serialize', () => {
228233 } ) ;
229234
230235 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+ ) ;
239248 expect ( args ) . toEqual < SearchNearAudioArgs > ( {
240249 nearAudio : NearAudioSearch . fromPartial ( {
241250 audio : 'audio' ,
@@ -248,7 +257,7 @@ describe('Unit testing of Serialize', () => {
248257 } ) ;
249258
250259 it ( 'should parse args for nearDepth' , ( ) => {
251- const args = Serialize . nearDepth ( {
260+ const args = Serialize . search . nearDepth ( {
252261 depth : 'depth' ,
253262 supportsTargets : false ,
254263 supportsWeightsForTargets : false ,
@@ -262,7 +271,7 @@ describe('Unit testing of Serialize', () => {
262271 } ) ;
263272
264273 it ( 'should parse args for nearIMU' , ( ) => {
265- const args = Serialize . nearIMU ( {
274+ const args = Serialize . search . nearIMU ( {
266275 imu : 'imu' ,
267276 supportsTargets : false ,
268277 supportsWeightsForTargets : false ,
@@ -276,7 +285,7 @@ describe('Unit testing of Serialize', () => {
276285 } ) ;
277286
278287 it ( 'should parse args for nearImage' , ( ) => {
279- const args = Serialize . nearImage ( {
288+ const args = Serialize . search . nearImage ( {
280289 image : 'image' ,
281290 supportsTargets : false ,
282291 supportsWeightsForTargets : false ,
@@ -290,7 +299,7 @@ describe('Unit testing of Serialize', () => {
290299 } ) ;
291300
292301 it ( 'should parse args for nearObject' , ( ) => {
293- const args = Serialize . nearObject ( {
302+ const args = Serialize . search . nearObject ( {
294303 id : 'id' ,
295304 supportsTargets : false ,
296305 supportsWeightsForTargets : false ,
@@ -304,21 +313,25 @@ describe('Unit testing of Serialize', () => {
304313 } ) ;
305314
306315 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 ,
318321 } ,
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+ ) ;
322335 expect ( args ) . toEqual < SearchNearTextArgs > ( {
323336 nearText : NearTextSearch . fromPartial ( {
324337 query : [ 'test' ] ,
@@ -338,7 +351,7 @@ describe('Unit testing of Serialize', () => {
338351 } ) ;
339352
340353 it ( 'should parse args for nearThermal' , ( ) => {
341- const args = Serialize . nearThermal ( {
354+ const args = Serialize . search . nearThermal ( {
342355 thermal : 'thermal' ,
343356 supportsTargets : false ,
344357 supportsWeightsForTargets : false ,
@@ -352,7 +365,7 @@ describe('Unit testing of Serialize', () => {
352365 } ) ;
353366
354367 it ( 'should parse args for nearVector with single vector' , ( ) => {
355- const args = Serialize . nearVector ( {
368+ const args = Serialize . search . nearVector ( {
356369 vector : [ 1 , 2 , 3 ] ,
357370 supportsTargets : false ,
358371 supportsVectorsForTargets : false ,
@@ -367,7 +380,7 @@ describe('Unit testing of Serialize', () => {
367380 } ) ;
368381
369382 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 ( {
371384 vector : {
372385 a : [ 1 , 2 , 3 ] ,
373386 b : [ 4 , 5 , 6 ] ,
@@ -389,7 +402,7 @@ describe('Unit testing of Serialize', () => {
389402 } ) ;
390403
391404 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 ( {
393406 vector : {
394407 a : [
395408 [ 1 , 2 , 3 ] ,
@@ -415,7 +428,7 @@ describe('Unit testing of Serialize', () => {
415428 } ) ;
416429
417430 it ( 'should parse args for nearVideo' , ( ) => {
418- const args = Serialize . nearVideo ( {
431+ const args = Serialize . search . nearVideo ( {
419432 video : 'video' ,
420433 supportsTargets : false ,
421434 supportsWeightsForTargets : false ,
@@ -444,7 +457,7 @@ describe('Unit testing of Serialize', () => {
444457 } ) ;
445458
446459 it ( 'should parse args for groupBy' , ( ) => {
447- const args = Serialize . groupBy ( {
460+ const args = Serialize . search . groupBy ( {
448461 property : 'name' ,
449462 numberOfGroups : 1 ,
450463 objectsPerGroup : 2 ,
@@ -457,14 +470,14 @@ describe('Unit testing of Serialize', () => {
457470 } ) ;
458471
459472 it ( 'should parse args for isGroupBy' , ( ) => {
460- const isGroupBy = Serialize . isGroupBy ( {
473+ const isGroupBy = Serialize . search . isGroupBy ( {
461474 groupBy : {
462475 property : 'name' ,
463476 numberOfGroups : 1 ,
464477 objectsPerGroup : 2 ,
465478 } ,
466479 } ) ;
467- const isNotGroupBy = Serialize . isGroupBy ( { } ) ;
480+ const isNotGroupBy = Serialize . search . isGroupBy ( { } ) ;
468481 expect ( isGroupBy ) . toEqual ( true ) ;
469482 expect ( isNotGroupBy ) . toEqual ( false ) ;
470483 } ) ;
0 commit comments