{"record":{"id":"17b1bfe60de6bfe9","repo":"ankane/searchkick","slug":"unknown-quantization-quantization","errorCode":null,"errorMessage":"Unknown quantization: #{quantization}","messagePattern":"Unknown quantization: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/searchkick/index_options.rb","lineNumber":502,"sourceCode":"              case distance\n              when \"cosine\"\n                \"cosine\"\n              when \"euclidean\"\n                \"l2_norm\"\n              when \"inner_product\"\n                \"max_inner_product\"\n              else\n                raise ArgumentError, \"Unknown distance: #{distance}\"\n              end\n\n            type =\n              case quantization\n              when \"int8\", \"int4\", \"bbq\"\n                \"#{quantization}_hnsw\"\n              when nil\n                \"hnsw\"\n              else\n                raise ArgumentError, \"Unknown quantization: #{quantization}\"\n              end\n\n            vector_index_options = knn_options.slice(:m, :ef_construction)\n            vector_options[:index_options] = {type: type}.merge(vector_index_options)\n          end\n\n          mapping[field.to_s] = vector_options\n        end\n      end\n\n      if options[:inheritance]\n        mapping[:type] = keyword_mapping\n      end\n\n      routing = {}\n      if options[:routing]\n        routing = {required: true}\n        unless options[:routing] == true","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/ankane/searchkick/blob/93e901a75b11a25101668a616e006b158251b16e/lib/searchkick/index_options.rb#L484-L520","documentation":"On Elasticsearch, quantization is expressed through the dense-vector field `type` suffix: `int8_hnsw`, `int4_hnsw`, or `bbq_hnsw` (and plain `hnsw` when unquantized). The case statement accepts only `\"int8\"`, `\"int4\"`, `\"bbq\"`, or `nil`; any other quantization value has no mapping type, so searchkick raises `ArgumentError` at mapping-build time.","triggerScenarios":"`searchkick knn: {embedding: {dimensions: 768, distance: \"cosine\", quantization: \"int8_hnsw\"}}` (passing the raw ES type instead of the abstract value), or `quantization: \"float8\"`, `\"binary\"`, or `:int8` (symbol) on Elasticsearch, then reindex.","commonSituations":"Copying `int8_hnsw`/`int4_hnsw` straight from Elasticsearch mapping docs into the searchkick option; using a vendor's or blog's quantization name that searchkick doesn't abstract; assuming symbols and strings are interchangeable here.","solutions":["Use `quantization: \"int8\"`, `\"int4\"`, or `\"bbq\"` — searchkick appends `_hnsw` itself.","Omit `quantization` entirely for full-precision HNSW.","Verify the ES version supports the type (bbq_hnsw needs ES 8.15+); otherwise pick int8/int4.","Reindex after the change."],"exampleFix":"# before\nsearchkick knn: {embedding: {dimensions: 768, distance: \"cosine\", quantization: \"int8_hnsw\"}}\n# => ArgumentError: Unknown quantization: int8_hnsw\n\n# after\nsearchkick knn: {embedding: {dimensions: 768, distance: \"cosine\", quantization: \"int8\"}}","handlingStrategy":"validation","validationCode":"SUPPORTED_QUANTIZATION = %w[int8 int4 bbq].freeze\nquant = \"int8\"\nraise ArgumentError, \"unsupported quantization #{quant}\" unless SUPPORTED_QUANTIZATION.include?(quant)\nclass Product < ApplicationRecord\n  searchkick knn: {embedding: {dimensions: 768, distance: \"cosine\", quantization: quant}}\nend","typeGuard":"def valid_knn_quantization?(quant)\n  quant.nil? || %w[int8 int4 bbq].include?(quant)\nend","tryCatchPattern":null,"preventionTips":["Use the abstract values (int8/int4/bbq); searchkick appends `_hnsw` itself.","Verify your ES server version supports the resulting type (bbq needs 8.15+).","Keep quantization out of configs that run against OpenSearch."],"tags":["searchkick","elasticsearch","knn","quantization","vector-search"],"backgroundTag":"unsupported-option-value","analyzedSha":"93e901a75b11a25101668a616e006b158251b16e","analyzedAt":"2026-08-21T19:06:23.767Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}