{"record":{"id":"bdb61cf99fe0bc1c","repo":"elastic/elasticsearch","slug":"vector-query-dimension-differs-from-field-dime-bdb61c","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/Float32VectorScorer.java","lineNumber":231,"sourceCode":"                numNodes,\n                addrsScratch::get,\n                addrs -> DISTANCE_FUNCS.dotProductF32BulkSparse(addrs, query, dimensions, numNodes, MemorySegment.ofArray(scores))\n            );\n            if (resolved) {\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            }\n            return super.bulkScore(nodes, scores, numNodes);\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":213,"sourceCodeEnd":235,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/simdvec/src/main/java/org/elasticsearch/simdvec/internal/Float32VectorScorer.java#L213-L235","documentation":"Thrown by Float32VectorScorer.checkDimensions when the query vector length does not equal the indexed field's vector dimension. This scorer handles standard float32 dense vectors. The check fires in the static create() method at scorer-construction time.","triggerScenarios":"Calling Float32VectorScorer.create(sim, values, queryVector) where queryVector.length != values.dimension().","commonSituations":"Querying a dense_vector field with an embedding from a different model/dimension, or after a mapping dims change without reindexing. The most common kNN dimension-mismatch scenario for float32 fields.","solutions":["Verify the field mapping dims (GET index/_mapping) and ensure the query vector has exactly that many elements.","Reindex documents if the embedding model or dimension changed.","Pre-validate the query vector length client-side before issuing the search."],"exampleFix":"// before\nfloat[] query = embed384(text); // field is dims:768\nscorer = Float32VectorScorer.create(sim, values, query);\n\n// after\nfloat[] query = embed768(text); // matches field dims\nscorer = Float32VectorScorer.create(sim, values, query);","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":["Validate the query vector length against the field mapping dims client-side.","Pin the embedding model version used at index and query time.","Reindex after any dims change."],"tags":["vector-search","knn","dimension-mismatch","float32","scorer","elasticsearch"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}