{"record":{"id":"5067ced6eb1be2e1","repo":"elastic/elasticsearch","slug":"cannot-add-statistics-without-field-names","errorCode":null,"errorMessage":"Cannot add statistics without field names.","messagePattern":"Cannot add statistics without field names\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/RunningStats.java","lineNumber":126,"sourceCode":"        out.writeGenericValue(fieldSum);\n        // counts\n        out.writeGenericValue(counts);\n        // mean\n        out.writeGenericValue(means);\n        // variances\n        out.writeGenericValue(variances);\n        // skewness\n        out.writeGenericValue(skewness);\n        // kurtosis\n        out.writeGenericValue(kurtosis);\n        // covariances\n        out.writeGenericValue(covariances);\n    }\n\n    /** updates running statistics with a documents field values **/\n    public void add(final String[] fieldNames, final double[] fieldVals) {\n        if (fieldNames == null) {\n            throw new IllegalArgumentException(\"Cannot add statistics without field names.\");\n        } else if (fieldVals == null) {\n            throw new IllegalArgumentException(\"Cannot add statistics without field values.\");\n        } else if (fieldNames.length != fieldVals.length) {\n            throw new IllegalArgumentException(\"Number of field values do not match number of field names.\");\n        }\n\n        // update total, mean, and variance\n        ++docCount;\n        String fieldName;\n        double fieldValue;\n        double m1, m2, m3, m4;  // moments\n        double d, dn, dn2, t1;\n        final HashMap<String, Double> deltas = new HashMap<>();\n        for (int i = 0; i < fieldNames.length; ++i) {\n            fieldName = fieldNames[i];\n            fieldValue = fieldVals[i];\n\n            // update counts","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/RunningStats.java#L108-L144","documentation":"Error \"Cannot add statistics without field names.\" thrown in elastic/elasticsearch.","triggerScenarios":"Thrown at modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/RunningStats.java:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}