{"record":{"id":"a1496f52b4df16d7","repo":"elastic/elasticsearch","slug":"aggregation-getname-all-fields-must-exist-in","errorCode":null,"errorMessage":"Aggregation [{getName()}] all fields must exist in all indices, but some indices are missing these fields [{fields}]","messagePattern":"Aggregation \\[(.+?)\\] all fields must exist in all indices, but some indices are missing these fields \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/InternalMatrixStats.java","lineNumber":252,"sourceCode":"            throw new IllegalArgumentException(\"path not supported for [\" + getName() + \"]: \" + path);\n        }\n    }\n\n    @Override\n    protected AggregatorReducer getLeaderReducer(AggregationReduceContext reduceContext, int size) {\n        return new AggregatorReducer() {\n            private RunningStats runningStats;\n\n            @Override\n            public void accept(InternalAggregation aggregation) {\n                final InternalMatrixStats internalMatrixStats = (InternalMatrixStats) aggregation;\n                if (internalMatrixStats.stats != null) {\n                    if (runningStats == null) {\n                        runningStats = new RunningStats();\n                    }\n                    final Set<String> missingFields = runningStats.missingFieldNames(internalMatrixStats.stats);\n                    if (missingFields.isEmpty() == false) {\n                        throw new IllegalArgumentException(\n                            \"Aggregation [\"\n                                + internalMatrixStats.getName()\n                                + \"] all fields must exist in all indices, but some indices are missing these fields [\"\n                                + String.join(\", \", new TreeSet<>(missingFields))\n                                + \"]\"\n                        );\n                    }\n                    runningStats.merge(internalMatrixStats.stats);\n                }\n            }\n\n            @Override\n            public InternalAggregation get() {\n                // return empty result iff all stats are null\n                if (runningStats == null) {\n                    return new InternalMatrixStats(name, 0, null, new MatrixStatsResults(), getMetadata());\n                }\n                if (reduceContext.isFinalReduce()) {","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/InternalMatrixStats.java#L234-L270","documentation":"Error \"Aggregation [{getName()}] all fields must exist in all indices, but some indices are missing these fields [{fields}]\" thrown in elastic/elasticsearch.","triggerScenarios":"Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/InternalMatrixStats.java:252 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}