Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ func compareFieldMapping(original, updated *mapping.FieldMapping) (*index.Update
if original.VectorIndexOptimizedFor != updated.VectorIndexOptimizedFor {
return nil, fmt.Errorf("vectorIndexOptimizedFor cannot be updated for vector and vector_base64 fields")
}
if original.UseGPU != updated.UseGPU {
return nil, fmt.Errorf("useGPU cannot be updated for vector and vector_base64 fields")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message uses "useGPU" to refer to this field, but the JSON tag is "gpu" and the struct field is "UseGPU". Other similar error messages in the codebase use the exact field property name or descriptive text. For consistency with line 512's error message "vectorIndexOptimizedFor cannot be updated", this should use "gpu cannot be updated" or maintain the same camelCase style as the JSON tag throughout.

Suggested change
return nil, fmt.Errorf("useGPU cannot be updated for vector and vector_base64 fields")
return nil, fmt.Errorf("gpu cannot be updated for vector and vector_base64 fields")

Copilot uses AI. Check for mistakes.
}
Comment on lines +514 to +516
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new UseGPU field validation logic lacks test coverage. The TestCompareFieldMapping function in index_update_test.go has comprehensive test cases for similar vector field properties like VectorIndexOptimizedFor (see line 127-142), but no test case exists for the UseGPU field. A test case should be added to verify that changing UseGPU for vector or vector_base64 fields correctly returns an error, following the same pattern as the VectorIndexOptimizedFor test.

Copilot uses AI. Check for mistakes.
}
if original.IncludeInAll != updated.IncludeInAll {
return nil, fmt.Errorf("includeInAll cannot be changed")
Expand Down
11 changes: 11 additions & 0 deletions mapping/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
VectorIndexOptimizedFor string `json:"vector_index_optimized_for,omitempty"`

SynonymSource string `json:"synonym_source,omitempty"`

// Flag that indicates whether to use GPU for field indexing and searching
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new GPU field lacks documentation. Similar vector field properties like VectorIndexOptimizedFor are documented in docs/vectors.md (line 32) and docs/index_update.md (line 24). The GPU field should be documented in both locations:

  1. docs/vectors.md should mention the gpu field option alongside other vector field properties
  2. docs/index_update.md should include gpu in the list of non-updatable vector field properties on line 24, updating it to mention that "Vector and VectorBase64 fields changing dims, similarity, vectorIndexOptimizedFor or gpu"
Suggested change
// Flag that indicates whether to use GPU for field indexing and searching
// Applicable to vector fields only - enables GPU acceleration for indexing
// and searching when the "gpu" field option is set in the mapping.

Copilot uses AI. Check for mistakes.
UseGPU bool `json:"gpu,omitempty"`
}

// NewTextFieldMapping returns a default field mapping for text
Expand Down Expand Up @@ -226,6 +229,9 @@
if fm.SkipFreqNorm {
rv |= index.SkipFreqNorm
}
if fm.UseGPU {
rv |= index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / coverage

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, windows-latest)

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.25.x, ubuntu-latest)

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, ubuntu-latest)

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.24.x, ubuntu-latest)

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.24.x, windows-latest)

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.24.x, macos-latest)

undefined: index.GPU

Check failure on line 233 in mapping/field.go

View workflow job for this annotation

GitHub Actions / test (1.23.x, macos-latest)

undefined: index.GPU
}
return rv
}

Expand Down Expand Up @@ -479,6 +485,11 @@
if err != nil {
return err
}
case "gpu":
err := util.UnmarshalJSON(v, &fm.UseGPU)
if err != nil {
return err
}
default:
invalidKeys = append(invalidKeys, k)
}
Expand Down
5 changes: 5 additions & 0 deletions mapping/mapping_vectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ func validateVectorFieldAlias(field *FieldMapping, path []string,
"(different vector index optimization values %s and %s)", effectiveFieldName,
effectiveOptimizedFor, aliasOptimizedFor)
}
if field.UseGPU != fieldAlias.UseGPU {
return fmt.Errorf("field: '%s', invalid alias "+
"(different useGPU values %v and %v)", fieldAlias.Name,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message uses 'fieldAlias.Name' to report the field name, but this is inconsistent with other error messages in the same function. All other error messages in validateVectorFieldAlias use 'effectiveFieldName' to report the field being validated. This inconsistency could cause confusion since fieldAlias.Name might be empty or differ from the effective field name used elsewhere in validation errors.

Suggested change
"(different useGPU values %v and %v)", fieldAlias.Name,
"(different useGPU values %v and %v)", effectiveFieldName,

Copilot uses AI. Check for mistakes.
field.UseGPU, fieldAlias.UseGPU)
}
Comment on lines +268 to +272
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new UseGPU alias validation logic lacks test coverage. The TestVectorFieldAliasValidation function in mapping/mapping_vectors_test.go has comprehensive test cases for other vector field properties including VectorIndexOptimizedFor (see test "different_optimization_alias" at line 180-207), but no test case exists to verify that fields with different UseGPU values are correctly rejected as invalid aliases. A test case should be added to ensure this validation works as expected.

Copilot uses AI. Check for mistakes.

return nil
}
Expand Down
Loading