Skip to content

Commit 46c4135

Browse files
committed
Toy: Forcing Cosine for binary indexes
1 parent 9d07cde commit 46c4135

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

mapping/mapping_vectors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ func validateVectorFieldAlias(field *FieldMapping, path []string,
234234
if effectiveOptimizedFor == "" {
235235
effectiveOptimizedFor = index.DefaultIndexOptimization
236236
}
237+
// If optimized for binary, similarity must be cosine
238+
if effectiveOptimizedFor == index.IndexOptimizedForBinary {
239+
field.Similarity = index.CosineSimilarity
240+
effectiveSimilarity = index.CosineSimilarity
241+
}
237242

238243
// # If alias is present, validate the field options as per the alias.
239244
// note: reading from a nil map is safe

0 commit comments

Comments
 (0)