{"record":{"id":"274d8e93e9dc7ed7","repo":"elastic/elasticsearch","slug":"vector-query-dimension-differs-from-field-dime-274d8e","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/Int7SQVectorScorer.java","lineNumber":238,"sourceCode":"            float[] maxScore = new float[] { Float.NEGATIVE_INFINITY };\n            boolean resolved = IndexInputUtils.withSliceAddresses(input, offsets, vectorPitch, numNodes, addrsScratch::get, addrs -> {\n                DISTANCE_FUNCS.dotProductI7uBulkSparse(addrs, query, vectorByteSize, numNodes, MemorySegment.ofArray(scores));\n                for (int i = 0; i < numNodes; ++i) {\n                    float adjustedDistance = scores[i] * scoreCorrectionConstant + queryCorrection + getNodeCorrection(addrs, i);\n                    scores[i] = VectorUtil.scaleMaxInnerProductScore(adjustedDistance);\n                    maxScore[0] = Math.max(maxScore[0], scores[i]);\n                }\n            });\n            if (resolved == false) {\n                return super.bulkScore(nodes, scores, numNodes);\n            }\n            return maxScore[0];\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":220,"sourceCodeEnd":242,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/simdvec/src/main/java/org/elasticsearch/simdvec/internal/Int7SQVectorScorer.java#L220-L242","documentation":"Thrown by Int7SQVectorScorer.checkDimensions when the query byte-array length does not equal the indexed field's vector dimension. Int7SQ (7-bit Scalar Quantization) stores vectors as bytes with 7-bit precision. The check fires in create() before building the scorer.","triggerScenarios":"Calling Int7SQVectorScorer.create(sim, values, queryVector) where queryVector.length (a byte[]) != values.dimension().","commonSituations":"Querying an int7-quantized field with a byte vector of the wrong length, or after changing quantization/dimension settings without reindexing. The query vector must be quantized to the same dimension as the stored vectors.","solutions":["Ensure the quantized query byte[] has exactly values.dimension() bytes.","Apply the same int7 quantization to the query as was used at index time.","Reindex if the field dimension or quantization configuration changed."],"exampleFix":"// before\nbyte[] q = quantize7bit(embed384(text)); // field dims:768\nscorer = Int7SQVectorScorer.create(sim, values, q);\n\n// after\nbyte[] q = quantize7bit(embed768(text));\nscorer = Int7SQVectorScorer.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":["Apply int7 quantization to the query at the same dimension as the indexed vectors.","Verify the byte[] length equals the field dimension before creating the scorer.","Reindex if quantization or dimension settings change."],"tags":["vector-search","knn","dimension-mismatch","int7","scalar-quantization","scorer","elasticsearch"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}