{"record":{"id":"936014ca2e4332bb","repo":"elastic/elasticsearch","slug":"can-t-advance-to-doc-using-936014","errorCode":null,"errorMessage":"Can't advance to doc using {}","messagePattern":"Can't advance to doc using (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScoreScript.java","lineNumber":90,"sourceCode":"                    return true;\n                }\n            });\n\n            @Override\n            public double execute(ExplanationHolder explanation) {\n                try {\n                    return values.doubleValue();\n                } catch (Exception exception) {\n                    throw new GeneralScriptException(\"Error evaluating \" + exprScript, exception);\n                }\n            }\n\n            @Override\n            public void setDocument(int d) {\n                try {\n                    values.advanceExact(d);\n                } catch (IOException e) {\n                    throw new IllegalStateException(\"Can't advance to doc using \" + exprScript, e);\n                }\n            }\n        };\n    }\n\n}\n","sourceCodeStart":72,"sourceCodeEnd":97,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScoreScript.java#L72-L97","documentation":"Thrown inside ExpressionScoreScript.setDocument(d) when values.advanceExact(d) raises IOException, wrapped in IllegalStateException with the expression source text. This is the score-script counterpart of errors 1220/1222 — the cursor cannot advance to the target document during score evaluation.","triggerScenarios":"Executing a function_score or script_score query with an expression script; advanceExact fails due to an I/O error reading the segment data for document d.","commonSituations":"Same class of I/O issues as 1220/1222: segment corruption, closed readers, concurrent merges, disk problems on the data node.","solutions":["Check index and shard health: GET _cluster/health?level=shards.","Inspect segment integrity: GET <index>/_segments and look for anomalies.","Refresh or restore: POST <index>/_refresh, or restore from snapshot if corruption is confirmed.","Verify no concurrent maintenance operations (force_merge, shrink, split) are running on the index."],"exampleFix":"// No code fix — runtime I/O failure during score evaluation.\n// Diagnose:\nGET _cluster/health?level=shards\nGET my-index/_segments\n// If corrupt: restore from snapshot","handlingStrategy":"try-catch","validationCode":"// Before running a script_score query, check shard and reader health\nGET _cluster/health/<index>?level=shards","typeGuard":null,"tryCatchPattern":"try {\n    scoreScript.setDocument(docId);\n} catch (IllegalStateException e) {\n    // I/O-level failure — typically unrecoverable for this reader\n    logger.error(\"Score expression advanceExact failed for doc [{}]: {}\", docId, e.getMessage(), e);\n    throw e;\n}","preventionTips":["Keep readers fresh — avoid holding stale Searcher references across refresh cycles.","Monitor disk I/O latency on data nodes; high latency often precedes these errors.","Schedule heavy operations (force_merge, reindex) outside peak query hours.","Maintain current snapshots for fast recovery from corruption."],"tags":["expression","script","score","io","lucene"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}