@@ -9,7 +9,7 @@ import { WeaviateInvalidInputError, WeaviateQueryError } from '../../errors.js';
9
9
import { Aggregator } from '../../graphql/index.js' ;
10
10
import { PrimitiveKeys , toBase64FromMedia } from '../../index.js' ;
11
11
import { Deserialize } from '../deserialize/index.js' ;
12
- import { Bm25QueryProperty , NearVectorInputType } from '../query/types.js' ;
12
+ import { Bm25QueryProperty , NearVectorInputType , TargetVector } from '../query/types.js' ;
13
13
import { NearVectorInputGuards } from '../query/utils.js' ;
14
14
import { Serialize } from '../serialize/index.js' ;
15
15
@@ -31,27 +31,27 @@ export type GroupByAggregate<T> = {
31
31
32
32
export type AggregateOverAllOptions < M > = AggregateBaseOptions < M > ;
33
33
34
- export type AggregateNearOptions < M > = AggregateBaseOptions < M > & {
34
+ export type AggregateNearOptions < M , V > = AggregateBaseOptions < M > & {
35
35
certainty ?: number ;
36
36
distance ?: number ;
37
37
objectLimit ?: number ;
38
- targetVector ?: string ;
38
+ targetVector ?: TargetVector < V > ;
39
39
} ;
40
40
41
- export type AggregateHybridOptions < T , M > = AggregateBaseOptions < M > & {
41
+ export type AggregateHybridOptions < T , M , V > = AggregateBaseOptions < M > & {
42
42
alpha ?: number ;
43
43
maxVectorDistance ?: number ;
44
44
objectLimit ?: number ;
45
45
queryProperties ?: ( PrimitiveKeys < T > | Bm25QueryProperty < T > ) [ ] ;
46
- targetVector ?: string ;
46
+ targetVector ?: TargetVector < V > ;
47
47
vector ?: number [ ] ;
48
48
} ;
49
49
50
- export type AggregateGroupByHybridOptions < T , M > = AggregateHybridOptions < T , M > & {
50
+ export type AggregateGroupByHybridOptions < T , M , V > = AggregateHybridOptions < T , M , V > & {
51
51
groupBy : PropertyOf < T > | GroupByAggregate < T > ;
52
52
} ;
53
53
54
- export type AggregateGroupByNearOptions < T , M > = AggregateNearOptions < M > & {
54
+ export type AggregateGroupByNearOptions < T , M , V > = AggregateNearOptions < M , V > & {
55
55
groupBy : PropertyOf < T > | GroupByAggregate < T > ;
56
56
} ;
57
57
@@ -346,9 +346,9 @@ export type AggregateGroupByResult<
346
346
} ;
347
347
} ;
348
348
349
- class AggregateManager < T > implements Aggregate < T > {
349
+ class AggregateManager < T , V > implements Aggregate < T , V > {
350
350
connection : Connection ;
351
- groupBy : AggregateGroupBy < T > ;
351
+ groupBy : AggregateGroupBy < T , V > ;
352
352
name : string ;
353
353
dbVersionSupport : DbVersionSupport ;
354
354
consistencyLevel ?: ConsistencyLevel ;
@@ -373,7 +373,7 @@ class AggregateManager<T> implements Aggregate<T> {
373
373
this . groupBy = {
374
374
hybrid : async < M extends PropertiesMetrics < T > > (
375
375
query : string ,
376
- opts : AggregateGroupByHybridOptions < T , M >
376
+ opts : AggregateGroupByHybridOptions < T , M , V >
377
377
) : Promise < AggregateGroupByResult < T , M > [ ] > => {
378
378
if ( await this . grpcChecker ) {
379
379
const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -402,7 +402,7 @@ class AggregateManager<T> implements Aggregate<T> {
402
402
} ,
403
403
nearImage : async < M extends PropertiesMetrics < T > > (
404
404
image : string | Buffer ,
405
- opts : AggregateGroupByNearOptions < T , M >
405
+ opts : AggregateGroupByNearOptions < T , M , V >
406
406
) : Promise < AggregateGroupByResult < T , M > [ ] > => {
407
407
const [ b64 , usesGrpc ] = await Promise . all ( [ await toBase64FromMedia ( image ) , await this . grpcChecker ] ) ;
408
408
if ( usesGrpc ) {
@@ -430,7 +430,7 @@ class AggregateManager<T> implements Aggregate<T> {
430
430
} ,
431
431
nearObject : async < M extends PropertiesMetrics < T > > (
432
432
id : string ,
433
- opts : AggregateGroupByNearOptions < T , M >
433
+ opts : AggregateGroupByNearOptions < T , M , V >
434
434
) : Promise < AggregateGroupByResult < T , M > [ ] > => {
435
435
if ( await this . grpcChecker ) {
436
436
const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -457,7 +457,7 @@ class AggregateManager<T> implements Aggregate<T> {
457
457
} ,
458
458
nearText : async < M extends PropertiesMetrics < T > > (
459
459
query : string | string [ ] ,
460
- opts : AggregateGroupByNearOptions < T , M >
460
+ opts : AggregateGroupByNearOptions < T , M , V >
461
461
) : Promise < AggregateGroupByResult < T , M > [ ] > => {
462
462
if ( await this . grpcChecker ) {
463
463
const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -484,7 +484,7 @@ class AggregateManager<T> implements Aggregate<T> {
484
484
} ,
485
485
nearVector : async < M extends PropertiesMetrics < T > > (
486
486
vector : number [ ] ,
487
- opts : AggregateGroupByNearOptions < T , M >
487
+ opts : AggregateGroupByNearOptions < T , M , V >
488
488
) : Promise < AggregateGroupByResult < T , M > [ ] > => {
489
489
if ( await this . grpcChecker ) {
490
490
const group = typeof opts . groupBy === 'string' ? { property : opts . groupBy } : opts . groupBy ;
@@ -593,19 +593,19 @@ class AggregateManager<T> implements Aggregate<T> {
593
593
return `${ propertyName } { ${ body } }` ;
594
594
}
595
595
596
- static use < T > (
596
+ static use < T , V > (
597
597
connection : Connection ,
598
598
name : string ,
599
599
dbVersionSupport : DbVersionSupport ,
600
600
consistencyLevel ?: ConsistencyLevel ,
601
601
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 ) ;
604
604
}
605
605
606
606
async hybrid < M extends PropertiesMetrics < T > > (
607
607
query : string ,
608
- opts ?: AggregateHybridOptions < T , M >
608
+ opts ?: AggregateHybridOptions < T , M , V >
609
609
) : Promise < AggregateResult < T , M > > {
610
610
if ( await this . grpcChecker ) {
611
611
return this . grpc ( )
@@ -628,7 +628,7 @@ class AggregateManager<T> implements Aggregate<T> {
628
628
629
629
async nearImage < M extends PropertiesMetrics < T > > (
630
630
image : string | Buffer ,
631
- opts ?: AggregateNearOptions < M >
631
+ opts ?: AggregateNearOptions < M , V >
632
632
) : Promise < AggregateResult < T , M > > {
633
633
const [ b64 , usesGrpc ] = await Promise . all ( [ await toBase64FromMedia ( image ) , await this . grpcChecker ] ) ;
634
634
if ( usesGrpc ) {
@@ -650,7 +650,7 @@ class AggregateManager<T> implements Aggregate<T> {
650
650
651
651
async nearObject < M extends PropertiesMetrics < T > > (
652
652
id : string ,
653
- opts ?: AggregateNearOptions < M >
653
+ opts ?: AggregateNearOptions < M , V >
654
654
) : Promise < AggregateResult < T , M > > {
655
655
if ( await this . grpcChecker ) {
656
656
return this . grpc ( )
@@ -671,7 +671,7 @@ class AggregateManager<T> implements Aggregate<T> {
671
671
672
672
async nearText < M extends PropertiesMetrics < T > > (
673
673
query : string | string [ ] ,
674
- opts ?: AggregateNearOptions < M >
674
+ opts ?: AggregateNearOptions < M , V >
675
675
) : Promise < AggregateResult < T , M > > {
676
676
if ( await this . grpcChecker ) {
677
677
return this . grpc ( )
@@ -692,7 +692,7 @@ class AggregateManager<T> implements Aggregate<T> {
692
692
693
693
async nearVector < M extends PropertiesMetrics < T > > (
694
694
vector : NearVectorInputType ,
695
- opts ?: AggregateNearOptions < M >
695
+ opts ?: AggregateNearOptions < M , V >
696
696
) : Promise < AggregateResult < T , M > > {
697
697
if ( await this . grpcChecker ) {
698
698
return this . grpc ( )
@@ -770,9 +770,9 @@ class AggregateManager<T> implements Aggregate<T> {
770
770
} ;
771
771
}
772
772
773
- export interface Aggregate < T > {
773
+ export interface Aggregate < T , V > {
774
774
/** This namespace contains methods perform a group by search while aggregating metrics. */
775
- groupBy : AggregateGroupBy < T > ;
775
+ groupBy : AggregateGroupBy < T , V > ;
776
776
/**
777
777
* Aggregate metrics over the objects returned by a hybrid search on this collection.
778
778
*
@@ -784,7 +784,7 @@ export interface Aggregate<T> {
784
784
*/
785
785
hybrid < M extends PropertiesMetrics < T > > (
786
786
query : string ,
787
- opts ?: AggregateHybridOptions < T , M >
787
+ opts ?: AggregateHybridOptions < T , M , V >
788
788
) : Promise < AggregateResult < T , M > > ;
789
789
/**
790
790
* Aggregate metrics over the objects returned by a near image vector search on this collection.
@@ -799,7 +799,7 @@ export interface Aggregate<T> {
799
799
*/
800
800
nearImage < M extends PropertiesMetrics < T > > (
801
801
image : string | Buffer ,
802
- opts ?: AggregateNearOptions < M >
802
+ opts ?: AggregateNearOptions < M , V >
803
803
) : Promise < AggregateResult < T , M > > ;
804
804
/**
805
805
* Aggregate metrics over the objects returned by a near object search on this collection.
@@ -814,7 +814,7 @@ export interface Aggregate<T> {
814
814
*/
815
815
nearObject < M extends PropertiesMetrics < T > > (
816
816
id : string ,
817
- opts ?: AggregateNearOptions < M >
817
+ opts ?: AggregateNearOptions < M , V >
818
818
) : Promise < AggregateResult < T , M > > ;
819
819
/**
820
820
* Aggregate metrics over the objects returned by a near vector search on this collection.
@@ -829,7 +829,7 @@ export interface Aggregate<T> {
829
829
*/
830
830
nearText < M extends PropertiesMetrics < T > > (
831
831
query : string | string [ ] ,
832
- opts ?: AggregateNearOptions < M >
832
+ opts ?: AggregateNearOptions < M , V >
833
833
) : Promise < AggregateResult < T , M > > ;
834
834
/**
835
835
* Aggregate metrics over the objects returned by a near vector search on this collection.
@@ -844,7 +844,7 @@ export interface Aggregate<T> {
844
844
*/
845
845
nearVector < M extends PropertiesMetrics < T > > (
846
846
vector : number [ ] ,
847
- opts ?: AggregateNearOptions < M >
847
+ opts ?: AggregateNearOptions < M , V >
848
848
) : Promise < AggregateResult < T , M > > ;
849
849
/**
850
850
* Aggregate metrics over all the objects in this collection without any vector search.
@@ -855,7 +855,7 @@ export interface Aggregate<T> {
855
855
overAll < M extends PropertiesMetrics < T > > ( opts ?: AggregateOverAllOptions < M > ) : Promise < AggregateResult < T , M > > ;
856
856
}
857
857
858
- export interface AggregateGroupBy < T > {
858
+ export interface AggregateGroupBy < T , V > {
859
859
/**
860
860
* Aggregate metrics over the objects grouped by a specified property and returned by a hybrid search on this collection.
861
861
*
@@ -867,7 +867,7 @@ export interface AggregateGroupBy<T> {
867
867
*/
868
868
hybrid < M extends PropertiesMetrics < T > > (
869
869
query : string ,
870
- opts : AggregateGroupByHybridOptions < T , M >
870
+ opts : AggregateGroupByHybridOptions < T , M , V >
871
871
) : Promise < AggregateGroupByResult < T , M > [ ] > ;
872
872
/**
873
873
* 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> {
882
882
*/
883
883
nearImage < M extends PropertiesMetrics < T > > (
884
884
image : string | Buffer ,
885
- opts : AggregateGroupByNearOptions < T , M >
885
+ opts : AggregateGroupByNearOptions < T , M , V >
886
886
) : Promise < AggregateGroupByResult < T , M > [ ] > ;
887
887
/**
888
888
* 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> {
897
897
*/
898
898
nearObject < M extends PropertiesMetrics < T > > (
899
899
id : string ,
900
- opts : AggregateGroupByNearOptions < T , M >
900
+ opts : AggregateGroupByNearOptions < T , M , V >
901
901
) : Promise < AggregateGroupByResult < T , M > [ ] > ;
902
902
/**
903
903
* 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> {
912
912
*/
913
913
nearText < M extends PropertiesMetrics < T > > (
914
914
query : string | string [ ] ,
915
- opts : AggregateGroupByNearOptions < T , M >
915
+ opts : AggregateGroupByNearOptions < T , M , V >
916
916
) : Promise < AggregateGroupByResult < T , M > [ ] > ;
917
917
/**
918
918
* 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> {
927
927
*/
928
928
nearVector < M extends PropertiesMetrics < T > > (
929
929
vector : number [ ] ,
930
- opts : AggregateGroupByNearOptions < T , M >
930
+ opts : AggregateGroupByNearOptions < T , M , V >
931
931
) : Promise < AggregateGroupByResult < T , M > [ ] > ;
932
932
/**
933
933
* Aggregate metrics over all the objects in this collection grouped by a specified property without any vector search.
0 commit comments