{"record":{"id":"721690e41ea7c0fb","repo":"pentaho/pentaho-kettle","slug":"elasticsearchbulk-error-nojsonfield","errorCode":"ElasticSearchBulk.Error.NoJsonField","errorMessage":"ElasticSearchBulk.Error.NoJsonField","messagePattern":"ElasticSearchBulk\\.Error\\.NoJsonField","errorType":"validation","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"plugins/elasticsearch-bulk-insert/core/src/main/java/org/pentaho/di/trans/steps/elasticsearchbulk/ElasticSearchBulk.java","lineNumber":163,"sourceCode":"   *\n   * @throws KettleStepException\n   */\n  private void setupData() throws KettleStepException {\n    data.nextBufferRowIdx = 0;\n    data.inputRowMeta = getInputRowMeta().clone(); // only available after first getRow();\n    data.inputRowBuffer = new Object[batchSize][];\n    data.outputRowMeta = data.inputRowMeta.clone();\n    meta.getFields( getTransMeta().getBowl(), data.outputRowMeta, getStepname(), null, null, this, repository,\n                    metaStore );\n  }\n\n  private void initFieldIndexes() throws KettleStepException {\n    if ( isJsonInsert ) {\n      Integer idx = getFieldIdx( data.inputRowMeta, environmentSubstitute( meta.getJsonField() ) );\n      if ( idx != null ) {\n        jsonFieldIdx = idx.intValue();\n      } else {\n        throw new KettleStepException( BaseMessages.getString( PKG, \"ElasticSearchBulk.Error.NoJsonField\" ) );\n      }\n    }\n\n    idOutFieldName = environmentSubstitute( meta.getIdOutField() );\n\n    if ( StringUtils.isNotBlank( meta.getIdInField() ) ) {\n      idFieldIndex = getFieldIdx( data.inputRowMeta, environmentSubstitute( meta.getIdInField() ) );\n      if ( idFieldIndex == null ) {\n        throw new KettleStepException( BaseMessages.getString( PKG, \"ElasticSearchBulk.Error.InvalidIdField\" ) );\n      }\n    } else {\n      idFieldIndex = null;\n    }\n  }\n\n  private static Integer getFieldIdx( RowMetaInterface rowMeta, String fieldName ) {\n    if ( fieldName == null ) {\n      return null;","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/elasticsearch-bulk-insert/core/src/main/java/org/pentaho/di/trans/steps/elasticsearchbulk/ElasticSearchBulk.java#L145-L181","documentation":"initFieldIndexes resolves the configured JSON field name to a column index in the incoming row. If the configured jsonField is not found in the input row layout, it throws KettleStepException 'ElasticSearchBulk.Error.NoJsonField'. The step cannot locate the field containing the JSON document to index.","triggerScenarios":"meta.getJsonField() names a field that does not exist in the input stream (getFieldIdx returns null) while isJsonInsert is true.","commonSituations":"Renamed or removed the JSON field upstream; typo in the field name in the step dialog; variable substitution (environmentSubstitute) resolving to an unexpected name; running the transformation with different input fields than designed.","solutions":["Verify the JSON field name in the step settings matches an incoming field exactly (case-sensitive)","Check any ${variable} used in the field name resolves at runtime","Add/fix the JSON field in the step feeding this one","Preview the input rows to confirm the field exists and its name"],"exampleFix":"// before\n// Json field: \"${JSON_COL}\" where JSON_COL is undefined -> field lookup returns null\n// after\n// define JSON_COL=doc in the transformation's environment settings, or set the literal field name","handlingStrategy":"validation","validationCode":"// before running, check the field exists in the input row meta\nboolean found = false;\nfor (ValueMetaInterface vm : inputRowMeta.getValueMetaList()) {\n  if (environmentSubstitute(jsonFieldName).equals(vm.getName())) { found = true; break; }\n}\nif (!found) throw new KettleStepException(\"Configured JSON field not in stream: \" + jsonFieldName);","typeGuard":null,"tryCatchPattern":"try { ... } catch (KettleStepException e) { if (e.getMessage().contains(\"NoJsonField\")) { logError(\"Fix the JSON field setting: \" + meta.getJsonField()); } throw e; }","preventionTips":["Preview upstream rows to confirm exact field names","Avoid renaming the JSON field upstream without updating this step","Test variable substitution used in the field name"],"tags":["elasticsearch","pdi","field-mapping","config"],"backgroundTag":"resource-not-found","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}