File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export interface HybridArgs {
33 query : string ;
44 vector ?: number [ ] ;
55 properties ?: string [ ] ;
6+ targetVectors ?: string [ ] ;
67 fusionType ?: FusionType ;
78}
89
@@ -16,13 +17,15 @@ export default class GraphQLHybrid {
1617 private query : string ;
1718 private vector ?: number [ ] ;
1819 private properties ?: string [ ] ;
20+ private targetVectors ?: string [ ] ;
1921 private fusionType ?: FusionType ;
2022
2123 constructor ( args : HybridArgs ) {
2224 this . alpha = args . alpha ;
2325 this . query = args . query ;
2426 this . vector = args . vector ;
2527 this . properties = args . properties ;
28+ this . targetVectors = args . targetVectors ;
2629 this . fusionType = args . fusionType ;
2730 }
2831
@@ -38,8 +41,11 @@ export default class GraphQLHybrid {
3841 }
3942
4043 if ( this . properties && this . properties . length > 0 ) {
41- const props = this . properties . join ( '","' ) ;
42- args = [ ...args , `properties:["${ props } "]` ] ;
44+ args = [ ...args , `properties:${ JSON . stringify ( this . properties ) } ` ] ;
45+ }
46+
47+ if ( this . targetVectors && this . targetVectors . length > 0 ) {
48+ args = [ ...args , `targetVectors:${ JSON . stringify ( this . targetVectors ) } ` ] ;
4349 }
4450
4551 if ( this . fusionType !== undefined ) {
Original file line number Diff line number Diff line change @@ -2243,6 +2243,22 @@ describe('named vectors test', () => {
22432243 } ) ;
22442244 } ) ;
22452245
2246+ it ( 'should perform a hybrid query on the rating vector' , ( ) => {
2247+ return client . graphql
2248+ . get ( )
2249+ . withClassName ( className )
2250+ . withHybrid ( {
2251+ query : 'Best' ,
2252+ targetVectors : [ 'rating' ] ,
2253+ } )
2254+ . withFields ( 'rating' )
2255+ . do ( )
2256+ . then ( ( res ) => {
2257+ expect ( res . data . Get . NamedVectorTest ) . toHaveLength ( 1 ) ;
2258+ expect ( res . data . Get . NamedVectorTest [ 0 ] . rating ) . toBe ( 'Best' ) ;
2259+ } ) ;
2260+ } ) ;
2261+
22462262 describe ( 'destroy' , ( ) => {
22472263 it ( 'tears down NamedVectorTest class' , ( ) => {
22482264 return client . schema . classDeleter ( ) . withClassName ( className ) . do ( ) ;
You can’t perform that action at this time.
0 commit comments