@@ -9,7 +9,7 @@ import { WeaviateInvalidInputError, WeaviateQueryError } from '../../errors.js';
99import { Aggregator } from '../../graphql/index.js' ;
1010import { PrimitiveKeys , toBase64FromMedia } from '../../index.js' ;
1111import { Deserialize } from '../deserialize/index.js' ;
12- import { Bm25QueryProperty , NearVectorInputType } from '../query/types.js' ;
12+ import { Bm25QueryProperty , NearVectorInputType , TargetVector } from '../query/types.js' ;
1313import { NearVectorInputGuards } from '../query/utils.js' ;
1414import { Serialize } from '../serialize/index.js' ;
1515
@@ -31,27 +31,27 @@ export type GroupByAggregate<T> = {
3131
3232export type AggregateOverAllOptions < M > = AggregateBaseOptions < M > ;
3333
34- export type AggregateNearOptions < M > = AggregateBaseOptions < M > & {
34+ export type AggregateNearOptions < M , V > = AggregateBaseOptions < M > & {
3535 certainty ?: number ;
3636 distance ?: number ;
3737 objectLimit ?: number ;
38- targetVector ?: string ;
38+ targetVector ?: TargetVector < V > ;
3939} ;
4040
41- export type AggregateHybridOptions < T , M > = AggregateBaseOptions < M > & {
41+ export type AggregateHybridOptions < T , M , V > = AggregateBaseOptions < M > & {
4242 alpha ?: number ;
4343 maxVectorDistance ?: number ;
4444 objectLimit ?: number ;
4545 queryProperties ?: ( PrimitiveKeys < T > | Bm25QueryProperty < T > ) [ ] ;
46- targetVector ?: string ;
46+ targetVector ?: TargetVector < V > ;
4747 vector ?: number [ ] ;
4848} ;
4949
50- export type AggregateGroupByHybridOptions < T , M > = AggregateHybridOptions < T , M > & {
50+ export type AggregateGroupByHybridOptions < T , M , V > = AggregateHybridOptions < T , M , V > & {
5151 groupBy : PropertyOf < T > | GroupByAggregate < T > ;
5252} ;
5353
54- export type AggregateGroupByNearOptions < T , M > = AggregateNearOptions < M > & {
54+ export type AggregateGroupByNearOptions < T , M , V > = AggregateNearOptions < M , V > & {
5555 groupBy : PropertyOf < T > | GroupByAggregate < T > ;
5656} ;
5757
@@ -346,9 +346,9 @@ export type AggregateGroupByResult<
346346 } ;
347347} ;
348348
349- class AggregateManager < T > implements Aggregate < T > {
349+ class AggregateManager < T , V > implements Aggregate < T , V > {
350350 connection : Connection ;
351- groupBy : AggregateGroupBy < T > ;
351+ groupBy : AggregateGroupBy < T , V > ;
352352 name : string ;
353353 dbVersionSupport : DbVersionSupport ;
354354 consistencyLevel ?: ConsistencyLevel ;
@@ -373,7 +373,7 @@ class AggregateManager<T> implements Aggregate<T> {
373373 this . groupBy = {
374374 hybrid : async < M extends PropertiesMetrics < T > > (
375375 query : string ,
376- opts : AggregateGroupByHybridOptions < T , M >
376+ opts : AggregateGroupByHybridOptions < T , M , V >
377377 ) : Promise < AggregateGroupByResult < T , M > [ ] > => {
378378 if ( await this . grpcChecker ) {
379379 const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -402,7 +402,7 @@ class AggregateManager<T> implements Aggregate<T> {
402402 } ,
403403 nearImage : async < M extends PropertiesMetrics < T > > (
404404 image : string | Buffer ,
405- opts : AggregateGroupByNearOptions < T , M >
405+ opts : AggregateGroupByNearOptions < T , M , V >
406406 ) : Promise < AggregateGroupByResult < T , M > [ ] > => {
407407 const [ b64 , usesGrpc ] = await Promise . all ( [ await toBase64FromMedia ( image ) , await this . grpcChecker ] ) ;
408408 if ( usesGrpc ) {
@@ -430,7 +430,7 @@ class AggregateManager<T> implements Aggregate<T> {
430430 } ,
431431 nearObject : async < M extends PropertiesMetrics < T > > (
432432 id : string ,
433- opts : AggregateGroupByNearOptions < T , M >
433+ opts : AggregateGroupByNearOptions < T , M , V >
434434 ) : Promise < AggregateGroupByResult < T , M > [ ] > => {
435435 if ( await this . grpcChecker ) {
436436 const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -457,7 +457,7 @@ class AggregateManager<T> implements Aggregate<T> {
457457 } ,
458458 nearText : async < M extends PropertiesMetrics < T > > (
459459 query : string | string [ ] ,
460- opts : AggregateGroupByNearOptions < T , M >
460+ opts : AggregateGroupByNearOptions < T , M , V >
461461 ) : Promise < AggregateGroupByResult < T , M > [ ] > => {
462462 if ( await this . grpcChecker ) {
463463 const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -484,7 +484,7 @@ class AggregateManager<T> implements Aggregate<T> {
484484 } ,
485485 nearVector : async < M extends PropertiesMetrics < T > > (
486486 vector : number [ ] ,
487- opts : AggregateGroupByNearOptions < T , M >
487+ opts : AggregateGroupByNearOptions < T , M , V >
488488 ) : Promise < AggregateGroupByResult < T , M > [ ] > => {
489489 if ( await this . grpcChecker ) {
490490 const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -593,19 +593,19 @@ class AggregateManager<T> implements Aggregate<T> {
593593 return `${ propertyName } { ${ body } }` ;
594594 }
595595
596- static use < T > (
596+ static use < T , V > (
597597 connection : Connection ,
598598 name : string ,
599599 dbVersionSupport : DbVersionSupport ,
600600 consistencyLevel ?: ConsistencyLevel ,
601601 tenant ?: string
602- ) : AggregateManager < T > {
603- return new AggregateManager < T > ( connection , name , dbVersionSupport , consistencyLevel , tenant ) ;
602+ ) : AggregateManager < T , V > {
603+ return new AggregateManager < T , V > ( connection , name , dbVersionSupport , consistencyLevel , tenant ) ;
604604 }
605605
606606 async hybrid < M extends PropertiesMetrics < T > > (
607607 query : string ,
608- opts ?: AggregateHybridOptions < T , M >
608+ opts ?: AggregateHybridOptions < T , M , V >
609609 ) : Promise < AggregateResult < T , M > > {
610610 if ( await this . grpcChecker ) {
611611 return this . grpc ( )
@@ -628,7 +628,7 @@ class AggregateManager<T> implements Aggregate<T> {
628628
629629 async nearImage < M extends PropertiesMetrics < T > > (
630630 image : string | Buffer ,
631- opts ?: AggregateNearOptions < M >
631+ opts ?: AggregateNearOptions < M , V >
632632 ) : Promise < AggregateResult < T , M > > {
633633 const [ b64 , usesGrpc ] = await Promise . all ( [ await toBase64FromMedia ( image ) , await this . grpcChecker ] ) ;
634634 if ( usesGrpc ) {
@@ -650,7 +650,7 @@ class AggregateManager<T> implements Aggregate<T> {
650650
651651 async nearObject < M extends PropertiesMetrics < T > > (
652652 id : string ,
653- opts ?: AggregateNearOptions < M >
653+ opts ?: AggregateNearOptions < M , V >
654654 ) : Promise < AggregateResult < T , M > > {
655655 if ( await this . grpcChecker ) {
656656 return this . grpc ( )
@@ -671,7 +671,7 @@ class AggregateManager<T> implements Aggregate<T> {
671671
672672 async nearText < M extends PropertiesMetrics < T > > (
673673 query : string | string [ ] ,
674- opts ?: AggregateNearOptions < M >
674+ opts ?: AggregateNearOptions < M , V >
675675 ) : Promise < AggregateResult < T , M > > {
676676 if ( await this . grpcChecker ) {
677677 return this . grpc ( )
@@ -692,7 +692,7 @@ class AggregateManager<T> implements Aggregate<T> {
692692
693693 async nearVector < M extends PropertiesMetrics < T > > (
694694 vector : NearVectorInputType ,
695- opts ?: AggregateNearOptions < M >
695+ opts ?: AggregateNearOptions < M , V >
696696 ) : Promise < AggregateResult < T , M > > {
697697 if ( await this . grpcChecker ) {
698698 return this . grpc ( )
@@ -770,9 +770,9 @@ class AggregateManager<T> implements Aggregate<T> {
770770 } ;
771771}
772772
773- export interface Aggregate < T > {
773+ export interface Aggregate < T , V > {
774774 /** This namespace contains methods perform a group by search while aggregating metrics. */
775- groupBy : AggregateGroupBy < T > ;
775+ groupBy : AggregateGroupBy < T , V > ;
776776 /**
777777 * Aggregate metrics over the objects returned by a hybrid search on this collection.
778778 *
@@ -784,7 +784,7 @@ export interface Aggregate<T> {
784784 */
785785 hybrid < M extends PropertiesMetrics < T > > (
786786 query : string ,
787- opts ?: AggregateHybridOptions < T , M >
787+ opts ?: AggregateHybridOptions < T , M , V >
788788 ) : Promise < AggregateResult < T , M > > ;
789789 /**
790790 * Aggregate metrics over the objects returned by a near image vector search on this collection.
@@ -799,7 +799,7 @@ export interface Aggregate<T> {
799799 */
800800 nearImage < M extends PropertiesMetrics < T > > (
801801 image : string | Buffer ,
802- opts ?: AggregateNearOptions < M >
802+ opts ?: AggregateNearOptions < M , V >
803803 ) : Promise < AggregateResult < T , M > > ;
804804 /**
805805 * Aggregate metrics over the objects returned by a near object search on this collection.
@@ -814,7 +814,7 @@ export interface Aggregate<T> {
814814 */
815815 nearObject < M extends PropertiesMetrics < T > > (
816816 id : string ,
817- opts ?: AggregateNearOptions < M >
817+ opts ?: AggregateNearOptions < M , V >
818818 ) : Promise < AggregateResult < T , M > > ;
819819 /**
820820 * Aggregate metrics over the objects returned by a near vector search on this collection.
@@ -829,7 +829,7 @@ export interface Aggregate<T> {
829829 */
830830 nearText < M extends PropertiesMetrics < T > > (
831831 query : string | string [ ] ,
832- opts ?: AggregateNearOptions < M >
832+ opts ?: AggregateNearOptions < M , V >
833833 ) : Promise < AggregateResult < T , M > > ;
834834 /**
835835 * Aggregate metrics over the objects returned by a near vector search on this collection.
@@ -844,7 +844,7 @@ export interface Aggregate<T> {
844844 */
845845 nearVector < M extends PropertiesMetrics < T > > (
846846 vector : number [ ] ,
847- opts ?: AggregateNearOptions < M >
847+ opts ?: AggregateNearOptions < M , V >
848848 ) : Promise < AggregateResult < T , M > > ;
849849 /**
850850 * Aggregate metrics over all the objects in this collection without any vector search.
@@ -855,7 +855,7 @@ export interface Aggregate<T> {
855855 overAll < M extends PropertiesMetrics < T > > ( opts ?: AggregateOverAllOptions < M > ) : Promise < AggregateResult < T , M > > ;
856856}
857857
858- export interface AggregateGroupBy < T > {
858+ export interface AggregateGroupBy < T , V > {
859859 /**
860860 * Aggregate metrics over the objects grouped by a specified property and returned by a hybrid search on this collection.
861861 *
@@ -867,7 +867,7 @@ export interface AggregateGroupBy<T> {
867867 */
868868 hybrid < M extends PropertiesMetrics < T > > (
869869 query : string ,
870- opts : AggregateGroupByHybridOptions < T , M >
870+ opts : AggregateGroupByHybridOptions < T , M , V >
871871 ) : Promise < AggregateGroupByResult < T , M > [ ] > ;
872872 /**
873873 * Aggregate metrics over the objects grouped by a specified property and returned by a near image vector search on this collection.
@@ -882,7 +882,7 @@ export interface AggregateGroupBy<T> {
882882 */
883883 nearImage < M extends PropertiesMetrics < T > > (
884884 image : string | Buffer ,
885- opts : AggregateGroupByNearOptions < T , M >
885+ opts : AggregateGroupByNearOptions < T , M , V >
886886 ) : Promise < AggregateGroupByResult < T , M > [ ] > ;
887887 /**
888888 * Aggregate metrics over the objects grouped by a specified property and returned by a near object search on this collection.
@@ -897,7 +897,7 @@ export interface AggregateGroupBy<T> {
897897 */
898898 nearObject < M extends PropertiesMetrics < T > > (
899899 id : string ,
900- opts : AggregateGroupByNearOptions < T , M >
900+ opts : AggregateGroupByNearOptions < T , M , V >
901901 ) : Promise < AggregateGroupByResult < T , M > [ ] > ;
902902 /**
903903 * Aggregate metrics over the objects grouped by a specified property and returned by a near text vector search on this collection.
@@ -912,7 +912,7 @@ export interface AggregateGroupBy<T> {
912912 */
913913 nearText < M extends PropertiesMetrics < T > > (
914914 query : string | string [ ] ,
915- opts : AggregateGroupByNearOptions < T , M >
915+ opts : AggregateGroupByNearOptions < T , M , V >
916916 ) : Promise < AggregateGroupByResult < T , M > [ ] > ;
917917 /**
918918 * Aggregate metrics over the objects grouped by a specified property and returned by a near vector search on this collection.
@@ -927,7 +927,7 @@ export interface AggregateGroupBy<T> {
927927 */
928928 nearVector < M extends PropertiesMetrics < T > > (
929929 vector : number [ ] ,
930- opts : AggregateGroupByNearOptions < T , M >
930+ opts : AggregateGroupByNearOptions < T , M , V >
931931 ) : Promise < AggregateGroupByResult < T , M > [ ] > ;
932932 /**
933933 * Aggregate metrics over all the objects in this collection grouped by a specified property without any vector search.
0 commit comments