{"record":{"id":"b7bbd940c1d2b742","repo":"elastic/elasticsearch","slug":"vector-query-dimension-differs-from-field-dime-b7bbd9","errorCode":null,"errorMessage":"vector query dimension: {} differs from field dimension: {}","messagePattern":"vector query dimension: (.+?) differs from field dimension: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/simdvec/src/main/java/org/elasticsearch/simdvec/internal/Int8VectorScorer.java","lineNumber":244,"sourceCode":"\n        @Override\n        public float bulkScore(int[] nodes, float[] scores, int numNodes) throws IOException {\n            if (bulkScoreWithSparse(nodes, scores, numNodes, DISTANCE_FUNCS::dotProductI8BulkSparse)) {\n                float max = Float.NEGATIVE_INFINITY;\n                for (int i = 0; i < numNodes; ++i) {\n                    scores[i] = VectorUtil.scaleMaxInnerProductScore(scores[i]);\n                    max = Math.max(max, scores[i]);\n                }\n                return max;\n            } else {\n                return super.bulkScore(nodes, scores, numNodes);\n            }\n        }\n    }\n\n    static void checkDimensions(int queryLen, int fieldLen) {\n        if (queryLen != fieldLen) {\n            throw new IllegalArgumentException(\"vector query dimension: \" + queryLen + \" differs from field dimension: \" + fieldLen);\n        }\n    }\n}\n","sourceCodeStart":226,"sourceCodeEnd":248,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/simdvec/src/main/java/org/elasticsearch/simdvec/internal/Int8VectorScorer.java#L226-L248","documentation":"Thrown by Int8VectorScorer.checkDimensions when the query byte-array length does not equal the indexed field's vector dimension. Int8VectorScorer handles 8-bit scalar-quantized vectors and uses native SIMD via SimdVecLibrary. The check runs in the static create() method before constructing the native scorer.","triggerScenarios":"Calling Int8VectorScorer.create(sim, values, queryVector) where queryVector.length (byte[]) != values.dimension().","commonSituations":"Querying an int8-quantized dense_vector field with a byte vector of mismatched length, or mixing quantized and raw float query vectors. Also occurs after reindexing at a new dimension without updating the query pipeline.","solutions":["Confirm the quantized query byte[] length equals the field's dimension.","Run the same int8 quantization on the query embedding as at index time.","Reindex if dims or quantization config changed."],"exampleFix":"// before\nbyte[] q = quantize8bit(embed384(text)); // field dims:768\nscorer = Int8VectorScorer.create(sim, values, q);\n\n// after\nbyte[] q = quantize8bit(embed768(text));\nscorer = Int8VectorScorer.create(sim, values, q);","handlingStrategy":"validation","validationCode":"if (queryVector.length != values.dimension()) {\n    throw new IllegalArgumentException(\"query dims \" + queryVector.length + \" != field dims \" + values.dimension());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quantize the query with the same int8 process used at index time.","Confirm byte[] length matches the field dimension.","Reindex after any quantization or dimension config change."],"tags":["vector-search","knn","dimension-mismatch","int8","scalar-quantization","scorer","elasticsearch"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}