@@ -140,7 +140,7 @@ describe('Testing of the collection.aggregate methods', () => {
140140 expect ( result [ 0 ] . totalCount ) . toEqual ( 100 ) ;
141141 expect ( result [ 0 ] . groupedBy . prop ) . toEqual ( 'text' ) ;
142142 expect ( result [ 0 ] . groupedBy . value ) . toEqual ( 'test' ) ;
143- expect ( result [ 0 ] . properties ) . toBeUndefined ( ) ;
143+ expect ( result [ 0 ] . properties ) . toEqual ( { } ) ;
144144 } ) ;
145145
146146 it ( 'should aggregate grouped by data with a near text search and no property metrics' , async ( ) => {
@@ -152,7 +152,7 @@ describe('Testing of the collection.aggregate methods', () => {
152152 expect ( result [ 0 ] . totalCount ) . toEqual ( 100 ) ;
153153 expect ( result [ 0 ] . groupedBy . prop ) . toEqual ( 'text' ) ;
154154 expect ( result [ 0 ] . groupedBy . value ) . toEqual ( 'test' ) ;
155- expect ( result [ 0 ] . properties ) . toBeUndefined ( ) ;
155+ expect ( result [ 0 ] . properties ) . toEqual ( { } ) ;
156156 } ) ;
157157
158158 it ( 'should aggregate data without a search and one generic property metric' , async ( ) => {
@@ -419,7 +419,7 @@ describe('Testing of collection.aggregate search methods', () => {
419419 ] ,
420420 vectorizers : weaviate . configure . vectorizer . text2VecContextionary ( ) ,
421421 } )
422- . then ( async ( ) => {
422+ . then ( ( ) => {
423423 const data : Array < any > = [ ] ;
424424 for ( let i = 0 ; i < 100 ; i ++ ) {
425425 data . push ( {
@@ -428,9 +428,10 @@ describe('Testing of collection.aggregate search methods', () => {
428428 } ,
429429 } ) ;
430430 }
431- await collection . data . insertMany ( data ) . then ( ( res ) => {
432- uuid = res . uuids [ 0 ] ;
433- } ) ;
431+ return collection . data . insertMany ( data ) ;
432+ } )
433+ . then ( ( res ) => {
434+ uuid = res . uuids [ 0 ] ;
434435 } ) ;
435436 } ) ;
436437
@@ -441,35 +442,76 @@ describe('Testing of collection.aggregate search methods', () => {
441442 queryProperties : [ 'text' ] ,
442443 returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
443444 } ) ;
444- expect ( result . totalCount ) . toEqual ( 100 ) ;
445- expect ( result . properties . text . count ) . toEqual ( 100 ) ;
445+ expect ( result . totalCount ) . toBeGreaterThan ( 0 ) ;
446+ } ) ;
447+
448+ it ( 'should return a grouped aggregation on a hybrid search' , async ( ) => {
449+ const result = await collection . aggregate . groupBy . hybrid ( 'test' , {
450+ objectLimit : 1000 ,
451+ groupBy : 'text' ,
452+ returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
453+ } ) ;
454+ expect ( result . length ) . toEqual ( 1 ) ;
455+ expect ( result [ 0 ] . groupedBy . prop ) . toEqual ( 'text' ) ;
456+ expect ( result [ 0 ] . groupedBy . value ) . toEqual ( 'test' ) ;
446457 } ) ;
447458
448459 it ( 'should return an aggregation on a nearText search' , async ( ) => {
449460 const result = await collection . aggregate . nearText ( 'test' , {
450- objectLimit : 100 ,
461+ objectLimit : 1000 ,
451462 returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
452463 } ) ;
453- expect ( result . totalCount ) . toEqual ( 100 ) ;
454- expect ( result . properties . text . count ) . toEqual ( 100 ) ;
464+ expect ( result . totalCount ) . toBeGreaterThan ( 0 ) ;
465+ } ) ;
466+
467+ it ( 'should return a grouped aggregation on a nearText search' , async ( ) => {
468+ const result = await collection . aggregate . groupBy . nearText ( 'test' , {
469+ objectLimit : 1000 ,
470+ groupBy : 'text' ,
471+ returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
472+ } ) ;
473+ expect ( result . length ) . toEqual ( 1 ) ;
474+ expect ( result [ 0 ] . groupedBy . prop ) . toEqual ( 'text' ) ;
475+ expect ( result [ 0 ] . groupedBy . value ) . toEqual ( 'test' ) ;
455476 } ) ;
456477
457478 it ( 'should return an aggregation on a nearVector search' , async ( ) => {
458479 const obj = await collection . query . fetchObjectById ( uuid , { includeVector : true } ) ;
459480 const result = await collection . aggregate . nearVector ( obj ?. vectors . default ! , {
460- objectLimit : 100 ,
481+ objectLimit : 1000 ,
461482 returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
462483 } ) ;
463- expect ( result . totalCount ) . toEqual ( 100 ) ;
464- expect ( result . properties . text . count ) . toEqual ( 100 ) ;
484+ expect ( result . totalCount ) . toBeGreaterThan ( 0 ) ;
485+ } ) ;
486+
487+ it ( 'should return a grouped aggregation on a nearVector search' , async ( ) => {
488+ const obj = await collection . query . fetchObjectById ( uuid , { includeVector : true } ) ;
489+ const result = await collection . aggregate . groupBy . nearVector ( obj ?. vectors . default ! , {
490+ objectLimit : 1000 ,
491+ groupBy : 'text' ,
492+ returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
493+ } ) ;
494+ expect ( result . length ) . toEqual ( 1 ) ;
495+ expect ( result [ 0 ] . groupedBy . prop ) . toEqual ( 'text' ) ;
496+ expect ( result [ 0 ] . groupedBy . value ) . toEqual ( 'test' ) ;
465497 } ) ;
466498
467499 it ( 'should return an aggregation on a nearObject search' , async ( ) => {
468500 const result = await collection . aggregate . nearObject ( uuid , {
469- objectLimit : 100 ,
501+ objectLimit : 1000 ,
470502 returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
471503 } ) ;
472- expect ( result . totalCount ) . toEqual ( 100 ) ;
473- expect ( result . properties . text . count ) . toEqual ( 100 ) ;
504+ expect ( result . totalCount ) . toBeGreaterThan ( 0 ) ;
505+ } ) ;
506+
507+ it ( 'should return a grouped aggregation on a nearText search' , async ( ) => {
508+ const result = await collection . aggregate . groupBy . nearObject ( uuid , {
509+ objectLimit : 1000 ,
510+ groupBy : 'text' ,
511+ returnMetrics : collection . metrics . aggregate ( 'text' ) . text ( [ 'count' ] ) ,
512+ } ) ;
513+ expect ( result . length ) . toEqual ( 1 ) ;
514+ expect ( result [ 0 ] . groupedBy . prop ) . toEqual ( 'text' ) ;
515+ expect ( result [ 0 ] . groupedBy . value ) . toEqual ( 'test' ) ;
474516 } ) ;
475517} ) ;
0 commit comments