@@ -483,11 +483,85 @@ describe.each([
483483
484484 test ( `${ permission } key: search without vectors` , async ( ) => {
485485 const client = await getClient ( permission ) ;
486- const response = await client . index ( index . uid ) . search ( 'prince' , { } ) ;
486+ const response = await client . index ( index . uid ) . searchGet ( 'prince' , { } ) ;
487487
488488 expect ( response ) . not . toHaveProperty ( 'semanticHitCount' ) ;
489489 } ) ;
490490
491+ test ( `${ permission } key: search with rankingScoreThreshold filter` , async ( ) => {
492+ const client = await getClient ( permission ) ;
493+
494+ const response = await client . index ( index . uid ) . searchGet ( 'prince' , {
495+ showRankingScore : true ,
496+ rankingScoreThreshold : 0.8 ,
497+ } ) ;
498+
499+ const hit = response . hits [ 0 ] ;
500+
501+ expect ( response ) . toHaveProperty ( 'hits' , expect . any ( Array ) ) ;
502+ expect ( response ) . toHaveProperty ( 'query' , 'prince' ) ;
503+ expect ( hit ) . toHaveProperty ( '_rankingScore' ) ;
504+ expect ( hit [ '_rankingScore' ] ) . toBeGreaterThanOrEqual ( 0.8 ) ;
505+
506+ const response2 = await client . index ( index . uid ) . search ( 'prince' , {
507+ showRankingScore : true ,
508+ rankingScoreThreshold : 0.9 ,
509+ } ) ;
510+
511+ expect ( response2 . hits . length ) . toBeLessThanOrEqual ( 0 ) ;
512+ } ) ;
513+
514+ test ( `${ permission } key: search with distinct` , async ( ) => {
515+ const client = await getClient ( permission ) ;
516+ const response = await client
517+ . index ( index . uid )
518+ . search ( '' , { distinct : 'genre' } ) ;
519+
520+ expect ( response . hits . length ) . toEqual ( 4 ) ;
521+ } ) ;
522+
523+ test ( `${ permission } key: search with retrieveVectors to true` , async ( ) => {
524+ const client = await getClient ( permission ) ;
525+ const adminKey = await getKey ( 'Admin' ) ;
526+
527+ await fetch ( `${ HOST } /experimental-features` , {
528+ body : JSON . stringify ( { vectorStore : true } ) ,
529+ headers : {
530+ Authorization : `Bearer ${ adminKey } ` ,
531+ 'Content-Type' : 'application/json' ,
532+ } ,
533+ method : 'PATCH' ,
534+ } ) ;
535+
536+ const response = await client . index ( index . uid ) . searchGet ( 'prince' , {
537+ retrieveVectors : true ,
538+ } ) ;
539+
540+ expect ( response ) . toHaveProperty ( 'hits' , expect . any ( Array ) ) ;
541+ expect ( response ) . toHaveProperty ( 'query' , 'prince' ) ;
542+ expect ( response . hits [ 0 ] ) . toHaveProperty ( '_vectors' ) ;
543+ } ) ;
544+
545+ test ( `${ permission } key: search without retrieveVectors` , async ( ) => {
546+ const client = await getClient ( permission ) ;
547+ const adminKey = await getKey ( 'Admin' ) ;
548+
549+ await fetch ( `${ HOST } /experimental-features` , {
550+ body : JSON . stringify ( { vectorStore : true } ) ,
551+ headers : {
552+ Authorization : `Bearer ${ adminKey } ` ,
553+ 'Content-Type' : 'application/json' ,
554+ } ,
555+ method : 'PATCH' ,
556+ } ) ;
557+
558+ const response = await client . index ( index . uid ) . searchGet ( 'prince' ) ;
559+
560+ expect ( response ) . toHaveProperty ( 'hits' , expect . any ( Array ) ) ;
561+ expect ( response ) . toHaveProperty ( 'query' , 'prince' ) ;
562+ expect ( response . hits [ 0 ] ) . not . toHaveProperty ( '_vectors' ) ;
563+ } ) ;
564+
491565 test ( `${ permission } key: Try to search on deleted index and fail` , async ( ) => {
492566 const client = await getClient ( permission ) ;
493567 const masterClient = await getClient ( 'Master' ) ;
0 commit comments