@@ -80,8 +80,9 @@ type FieldSchema struct {
80
80
}
81
81
82
82
type FTVectorArgs struct {
83
- FlatOptions * FTFlatOptions
84
- HNSWOptions * FTHNSWOptions
83
+ FlatOptions * FTFlatOptions
84
+ HNSWOptions * FTHNSWOptions
85
+ VamanaOptions * FTVamanaOptions
85
86
}
86
87
87
88
type FTFlatOptions struct {
@@ -103,6 +104,19 @@ type FTHNSWOptions struct {
103
104
Epsilon float64
104
105
}
105
106
107
+ type FTVamanaOptions struct {
108
+ Type string
109
+ Dim int
110
+ DistanceMetric string
111
+ Compression string
112
+ ConstructionWindowSize int
113
+ GraphMaxDegree int
114
+ SearchWindowSize int
115
+ Epsilon float64
116
+ TrainingThreshold int
117
+ ReduceDim int
118
+ }
119
+
106
120
type FTDropIndexOptions struct {
107
121
DeleteDocs bool
108
122
}
@@ -985,8 +999,19 @@ func (c cmdable) FTCreate(ctx context.Context, index string, options *FTCreateOp
985
999
if schema .FieldType != SearchFieldTypeVector {
986
1000
panic ("FT.CREATE: SCHEMA FieldType VECTOR is required for VectorArgs" )
987
1001
}
988
- if schema .VectorArgs .FlatOptions != nil && schema .VectorArgs .HNSWOptions != nil {
989
- panic ("FT.CREATE: SCHEMA VectorArgs FlatOptions and HNSWOptions are mutually exclusive" )
1002
+ // Check mutual exclusivity of vector options
1003
+ optionCount := 0
1004
+ if schema .VectorArgs .FlatOptions != nil {
1005
+ optionCount ++
1006
+ }
1007
+ if schema .VectorArgs .HNSWOptions != nil {
1008
+ optionCount ++
1009
+ }
1010
+ if schema .VectorArgs .VamanaOptions != nil {
1011
+ optionCount ++
1012
+ }
1013
+ if optionCount != 1 {
1014
+ panic ("FT.CREATE: SCHEMA VectorArgs must have exactly one of FlatOptions, HNSWOptions, or VamanaOptions" )
990
1015
}
991
1016
if schema .VectorArgs .FlatOptions != nil {
992
1017
args = append (args , "FLAT" )
@@ -1035,6 +1060,40 @@ func (c cmdable) FTCreate(ctx context.Context, index string, options *FTCreateOp
1035
1060
args = append (args , len (hnswArgs ))
1036
1061
args = append (args , hnswArgs ... )
1037
1062
}
1063
+ if schema .VectorArgs .VamanaOptions != nil {
1064
+ args = append (args , "VAMANA" )
1065
+ if schema .VectorArgs .VamanaOptions .Type == "" || schema .VectorArgs .VamanaOptions .Dim == 0 || schema .VectorArgs .VamanaOptions .DistanceMetric == "" {
1066
+ panic ("FT.CREATE: Type, Dim and DistanceMetric are required for VECTOR VAMANA" )
1067
+ }
1068
+ vamanaArgs := []interface {}{
1069
+ "TYPE" , schema .VectorArgs .VamanaOptions .Type ,
1070
+ "DIM" , schema .VectorArgs .VamanaOptions .Dim ,
1071
+ "DISTANCE_METRIC" , schema .VectorArgs .VamanaOptions .DistanceMetric ,
1072
+ }
1073
+ if schema .VectorArgs .VamanaOptions .Compression != "" {
1074
+ vamanaArgs = append (vamanaArgs , "COMPRESSION" , schema .VectorArgs .VamanaOptions .Compression )
1075
+ }
1076
+ if schema .VectorArgs .VamanaOptions .ConstructionWindowSize > 0 {
1077
+ vamanaArgs = append (vamanaArgs , "CONSTRUCTION_WINDOW_SIZE" , schema .VectorArgs .VamanaOptions .ConstructionWindowSize )
1078
+ }
1079
+ if schema .VectorArgs .VamanaOptions .GraphMaxDegree > 0 {
1080
+ vamanaArgs = append (vamanaArgs , "GRAPH_MAX_DEGREE" , schema .VectorArgs .VamanaOptions .GraphMaxDegree )
1081
+ }
1082
+ if schema .VectorArgs .VamanaOptions .SearchWindowSize > 0 {
1083
+ vamanaArgs = append (vamanaArgs , "SEARCH_WINDOW_SIZE" , schema .VectorArgs .VamanaOptions .SearchWindowSize )
1084
+ }
1085
+ if schema .VectorArgs .VamanaOptions .Epsilon > 0 {
1086
+ vamanaArgs = append (vamanaArgs , "EPSILON" , schema .VectorArgs .VamanaOptions .Epsilon )
1087
+ }
1088
+ if schema .VectorArgs .VamanaOptions .TrainingThreshold > 0 {
1089
+ vamanaArgs = append (vamanaArgs , "TRAINING_THRESHOLD" , schema .VectorArgs .VamanaOptions .TrainingThreshold )
1090
+ }
1091
+ if schema .VectorArgs .VamanaOptions .ReduceDim > 0 {
1092
+ vamanaArgs = append (vamanaArgs , "REDUCE" , schema .VectorArgs .VamanaOptions .ReduceDim )
1093
+ }
1094
+ args = append (args , len (vamanaArgs ))
1095
+ args = append (args , vamanaArgs ... )
1096
+ }
1038
1097
}
1039
1098
if schema .GeoShapeFieldType != "" {
1040
1099
if schema .FieldType != SearchFieldTypeGeoShape {
0 commit comments