Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better naming
Browse files Browse the repository at this point in the history
metonymic-smokey committed Jan 10, 2024
1 parent 5bd23bc commit 477ef28
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions document/field_vector.go
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ type VectorField struct {
value []float32
numPlainTextBytes uint64

indextype string
indexOptimization string // Optimization applied to this index.
}

func (n *VectorField) Size() int {
@@ -116,7 +116,7 @@ func NewVectorFieldWithIndexingOptions(name string, arrayPositions []uint64,
options: options,
value: vector,
numPlainTextBytes: numBytesFloat32s(vector),
indextype: indexType,
indexOptimization: indexType,
}
}

@@ -140,6 +140,6 @@ func (n *VectorField) Similarity() string {
return n.similarity
}

func (n *VectorField) IndexType() string {
return n.indextype
func (n *VectorField) IndexOptimization() string {
return n.indexOptimization
}
5 changes: 3 additions & 2 deletions mapping/field.go
Original file line number Diff line number Diff line change
@@ -78,7 +78,8 @@ type FieldMapping struct {
// See: index.DefaultSimilarityMetric & index.SupportedSimilarityMetrics
Similarity string `json:"similarity,omitempty"`

VectorIndexType string `json:"vector_index_type,omitempty"`
// The type of index based on the parameter to optimize for.
VectorIndexType string `json:"vector_index_optimize_for,omitempty"`
}

// NewTextFieldMapping returns a default field mapping for text
@@ -468,7 +469,7 @@ func (fm *FieldMapping) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
case "vector_index_type":
case "vector_index_optimize_for":
err := json.Unmarshal(v, &fm.VectorIndexType)
if err != nil {
return err
6 changes: 3 additions & 3 deletions mapping/mapping_vectors.go
Original file line number Diff line number Diff line change
@@ -163,7 +163,7 @@ func validateVectorFieldAlias(field *FieldMapping, parentName string,
}

if field.VectorIndexType == "" {
field.VectorIndexType = index.DefaultIndexType
field.VectorIndexType = index.DefaultIndexOptimization
}

// following fields are not applicable for vector
@@ -206,10 +206,10 @@ func validateVectorFieldAlias(field *FieldMapping, parentName string,
reflect.ValueOf(index.SupportedSimilarityMetrics).MapKeys())
}

if _, ok := index.SupportedIndexTunables[field.VectorIndexType]; !ok {
if _, ok := index.SupportedIndexConfigOptimizations[field.VectorIndexType]; !ok {
return fmt.Errorf("field: '%s', invalid index optimisation "+
"tunable: '%s', valid values are: %+v", field.Name, field.VectorIndexType,
reflect.ValueOf(index.SupportedIndexTunables).MapKeys())
reflect.ValueOf(index.SupportedIndexConfigOptimizations).MapKeys())
}

if fieldAliasCtx != nil { // writing to a nil map is unsafe

0 comments on commit 477ef28

Please sign in to comment.