@@ -116,13 +116,14 @@ public static bool CanSetJsonProperty(
116
116
/// <param name="distanceFunction">The distance function for a vector comparisons.</param>
117
117
/// <param name="dimensions">The number of dimensions in the vector.</param>
118
118
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
119
- [ Experimental ( EFDiagnostics . CosmosVectorSearchExperimental ) ]
120
- public static PropertyBuilder IsVector (
119
+ public static PropertyBuilder IsVectorProperty (
121
120
this PropertyBuilder propertyBuilder ,
122
121
DistanceFunction distanceFunction ,
123
122
int dimensions )
124
123
{
125
- propertyBuilder . Metadata . SetVectorType ( CreateVectorType ( distanceFunction , dimensions ) ) ;
124
+ propertyBuilder . Metadata . SetVectorDistanceFunction ( ValidateVectorDistanceFunction ( distanceFunction ) ) ;
125
+ propertyBuilder . Metadata . SetVectorDimensions ( dimensions ) ;
126
+
126
127
return propertyBuilder ;
127
128
}
128
129
@@ -142,12 +143,11 @@ public static PropertyBuilder IsVector(
142
143
/// <param name="distanceFunction">The distance function for a vector comparisons.</param>
143
144
/// <param name="dimensions">The number of dimensions in the vector.</param>
144
145
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
145
- [ Experimental ( EFDiagnostics . CosmosVectorSearchExperimental ) ]
146
- public static PropertyBuilder < TProperty > IsVector < TProperty > (
146
+ public static PropertyBuilder < TProperty > IsVectorProperty < TProperty > (
147
147
this PropertyBuilder < TProperty > propertyBuilder ,
148
148
DistanceFunction distanceFunction ,
149
149
int dimensions )
150
- => ( PropertyBuilder < TProperty > ) IsVector ( ( PropertyBuilder ) propertyBuilder , distanceFunction , dimensions ) ;
150
+ => ( PropertyBuilder < TProperty > ) IsVectorProperty ( ( PropertyBuilder ) propertyBuilder , distanceFunction , dimensions ) ;
151
151
152
152
/// <summary>
153
153
/// Configures the property as a vector for Azure Cosmos DB.
@@ -164,25 +164,25 @@ public static PropertyBuilder<TProperty> IsVector<TProperty>(
164
164
/// The same builder instance if the configuration was applied,
165
165
/// <see langword="null" /> otherwise.
166
166
/// </returns>
167
- [ Experimental ( EFDiagnostics . CosmosVectorSearchExperimental ) ]
168
- public static IConventionPropertyBuilder ? IsVector (
167
+ public static IConventionPropertyBuilder ? IsVectorProperty (
169
168
this IConventionPropertyBuilder propertyBuilder ,
170
169
DistanceFunction distanceFunction ,
171
170
int dimensions ,
172
171
bool fromDataAnnotation = false )
173
172
{
174
- if ( ! propertyBuilder . CanSetIsVector ( distanceFunction , dimensions , fromDataAnnotation ) )
173
+ if ( ! propertyBuilder . CanSetIsVectorProperty ( distanceFunction , dimensions , fromDataAnnotation ) )
175
174
{
176
175
return null ;
177
176
}
178
177
179
- propertyBuilder . Metadata . SetVectorType ( CreateVectorType ( distanceFunction , dimensions ) , fromDataAnnotation ) ;
178
+ propertyBuilder . Metadata . SetVectorDistanceFunction ( ValidateVectorDistanceFunction ( distanceFunction ) , fromDataAnnotation ) ;
179
+ propertyBuilder . Metadata . SetVectorDimensions ( dimensions , fromDataAnnotation ) ;
180
180
181
181
return propertyBuilder ;
182
182
}
183
183
184
184
/// <summary>
185
- /// Returns a value indicating whether the vector type can be set.
185
+ /// Returns a value indicating whether the vector distance function and dimensions can be set.
186
186
/// </summary>
187
187
/// <remarks>
188
188
/// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
@@ -192,18 +192,30 @@ public static PropertyBuilder<TProperty> IsVector<TProperty>(
192
192
/// <param name="distanceFunction">The distance function for a vector comparisons.</param>
193
193
/// <param name="dimensions">The number of dimensions in the vector.</param>
194
194
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
195
- /// <returns><see langword="true" /> if the vector type can be set.</returns>
196
- [ Experimental ( EFDiagnostics . CosmosVectorSearchExperimental ) ]
197
- public static bool CanSetIsVector (
195
+ /// <returns><see langword="true" /> if the vector distance function and dimensions can be set.</returns>
196
+ public static bool CanSetIsVectorProperty (
198
197
this IConventionPropertyBuilder propertyBuilder ,
199
198
DistanceFunction distanceFunction ,
200
199
int dimensions ,
201
200
bool fromDataAnnotation = false )
202
201
=> propertyBuilder . CanSetAnnotation (
203
- CosmosAnnotationNames . VectorType ,
204
- CreateVectorType ( distanceFunction , dimensions ) ,
202
+ CosmosAnnotationNames . VectorDistanceFunction ,
203
+ ValidateVectorDistanceFunction ( distanceFunction ) ,
204
+ fromDataAnnotation )
205
+ && propertyBuilder . CanSetAnnotation (
206
+ CosmosAnnotationNames . VectorDimensions ,
207
+ dimensions ,
205
208
fromDataAnnotation ) ;
206
209
210
+ private static DistanceFunction ValidateVectorDistanceFunction ( DistanceFunction distanceFunction )
211
+ => Enum . IsDefined ( distanceFunction )
212
+ ? distanceFunction
213
+ : throw new ArgumentException (
214
+ CoreStrings . InvalidEnumValue (
215
+ distanceFunction ,
216
+ nameof ( distanceFunction ) ,
217
+ typeof ( DistanceFunction ) ) ) ;
218
+
207
219
/// <summary>
208
220
/// Configures this property to be the etag concurrency token.
209
221
/// </summary>
@@ -237,13 +249,6 @@ public static PropertyBuilder<TProperty> IsETagConcurrency<TProperty>(
237
249
this PropertyBuilder < TProperty > propertyBuilder )
238
250
=> ( PropertyBuilder < TProperty > ) IsETagConcurrency ( ( PropertyBuilder ) propertyBuilder ) ;
239
251
240
- [ Experimental ( EFDiagnostics . CosmosVectorSearchExperimental ) ]
241
- private static CosmosVectorType CreateVectorType ( DistanceFunction distanceFunction , int dimensions )
242
- => Enum . IsDefined ( distanceFunction )
243
- ? new CosmosVectorType ( distanceFunction , dimensions )
244
- : throw new ArgumentException (
245
- CoreStrings . InvalidEnumValue ( distanceFunction , nameof ( distanceFunction ) , typeof ( DistanceFunction ) ) ) ;
246
-
247
252
/// <summary>
248
253
/// Enables full-text search for this property using a specified language.
249
254
/// </summary>
0 commit comments