{"record":{"id":"10de5426e61d1af0","repo":"redis/redis-rb","slug":"vector-fields-cannot-have-no-index-option","errorCode":null,"errorMessage":"Vector fields cannot have no_index option","messagePattern":"Vector fields cannot have no_index option","errorType":"exception","errorClass":"Redis::CommandError","httpStatus":null,"severity":"error","filePath":"lib/redis/commands/modules/search/field.rb","lineNumber":256,"sourceCode":"        # @param [String, Symbol] name the document attribute the field indexes\n        # @param [String, Symbol] algorithm the indexing method, one of +FLAT+, +HNSW+, +SVS-VAMANA+\n        # @param [Hash] attributes the vector attributes (e.g. +type+, +dim+, +distance_metric+)\n        # @option options [String] :as an alias for the field, rendered as +AS <alias>+\n        # @raise [ArgumentError] if +algorithm+ is not a supported indexing method\n        # @raise [Redis::CommandError] if +:sortable+ or +:no_index+ is given\n        def initialize(name, algorithm, attributes = {}, **options)\n          # Validate algorithm\n          unless ['FLAT', 'HNSW', 'SVS-VAMANA'].include?(algorithm.to_s.upcase)\n            raise ArgumentError,\n                  \"Realtime vector indexing supporting 3 Indexing Methods: 'FLAT', 'HNSW', and 'SVS-VAMANA'\"\n          end\n\n          # Validate that sortable and no_index are not used with vector fields\n          if options[:sortable]\n            raise Redis::CommandError, \"Vector fields cannot be sortable\"\n          end\n          if options[:no_index]\n            raise Redis::CommandError, \"Vector fields cannot have no_index option\"\n          end\n\n          super(name, :vector, **options)\n          @algorithm = algorithm.to_s.upcase\n          @attributes = attributes.transform_keys { |k| k.to_s.upcase }.transform_values { |v| v.to_s.upcase }\n        end\n\n        # Set or override a single vector attribute.\n        #\n        # @param [String, Symbol] key the attribute name (upcased internally)\n        # @param [Object] value the attribute value\n        # @return [Object] the stored value\n        def add_attribute(key, value)\n          # Normalize like #initialize does for the kwargs form, so block-DSL attributes\n          # (vector_field(...) { type \"float32\" }) reach FT.CREATE with the expected casing.\n          @attributes[key.to_s.upcase] = value.to_s.upcase\n        end\n","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/commands/modules/search/field.rb#L238-L274","documentation":"NOINDEX on a VECTOR field is rejected client-side: vector fields exist solely to be searched (KNN and vector range queries), so an unindexed vector column is meaningless. Unlike TAG or TEXT there is no store-but-do-not-index use case, so VectorField raises Redis::CommandError for no_index: true before FT.CREATE is sent (lib/redis/commands/modules/search/field.rb:256).","triggerScenarios":"VectorField.new(\"emb\", \"HNSW\", attrs, no_index: true); reusing a metadata options hash (which used no_index to skip indexing) for a new embedding field.","commonSituations":"Schemas that mark helper fields NOINDEX by convention; adding embeddings to an existing document model and copying field boilerplate; storing raw vectors next to indexed ones under one shared definition.","solutions":["Remove no_index from the vector field","Store unindexed raw vectors as ordinary document attributes outside the schema instead of as a VECTOR field","Keep separate option sets for metadata fields and vector fields"],"exampleFix":"// before\nVectorField.new(\"emb\", \"HNSW\", attrs, no_index: true)\n// after\nVectorField.new(\"emb\", \"HNSW\", attrs) # raw copy lives in a non-schema attribute","handlingStrategy":"validation","validationCode":"def vector_field(name, algo, attrs, opts)\n  VectorField.new(name, algo, attrs, **opts.except(:no_index, :sortable))\nend","typeGuard":"field.is_a?(Redis::Commands::Search::Field::VectorField) ? opts.except(:no_index) : opts","tryCatchPattern":"begin\n  VectorField.new(name, algo, attrs, **opts)\nrescue Redis::CommandError => e\n  raise SchemaConfigError, \"vector field rejected: #{e.message}\"\nend","preventionTips":["Keep separate option sets for metadata fields and vector fields","Store raw unindexed vectors outside the schema as plain document attributes","Strip no_index in any builder shared across field types"],"tags":["redis-search","vector-field","noindex","commanderror","schema"],"backgroundTag":"invalid-option-combination","analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}