{"record":{"id":"10181d6b169ff593","repo":"pentaho/pentaho-kettle","slug":"elasticsearchbulk-error-invalididfield","errorCode":"ElasticSearchBulk.Error.InvalidIdField","errorMessage":"ElasticSearchBulk.Error.InvalidIdField","messagePattern":"ElasticSearchBulk\\.Error\\.InvalidIdField","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":172,"sourceCode":"                    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;\n    }\n\n    for ( int i = 0; i < rowMeta.size(); i++ ) {\n      String name = rowMeta.getValueMeta( i ).getName();\n      if ( fieldName.equals( name ) ) {\n        return i;\n      }\n    }\n    return null;","sourceCodeStart":154,"sourceCodeEnd":190,"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#L154-L190","documentation":"initFieldIndexes also resolves the configured 'id in field' name to an index. If a non-blank idInField is configured but not present in the input row, KettleStepException 'ElasticSearchBulk.Error.InvalidIdField' is thrown. The step cannot use the specified field as the document _id.","triggerScenarios":"meta.getIdInField() is non-blank but getFieldIdx cannot find that field name in data.inputRowMeta.","commonSituations":"Typo or renamed id field upstream; variable in the field name not substituted; the id field removed by a Select values step; mismatch between dialog configuration and actual stream fields.","solutions":["Ensure the 'id field' configured in the step exists in the incoming stream (case-sensitive)","Verify environment variables in the field name resolve correctly","Re-add the id field upstream or clear the id field setting if unused","Preview the stream to list actual field names"],"exampleFix":"// before\n// idInField = \"uuid\" but stream only has \"id\"\n// after\n// set id field to \"id\" or add a Select values step renaming id -> uuid","handlingStrategy":"validation","validationCode":"// ensure the id field exists in the stream before this step\nint idx = inputRowMeta.indexOfValue(environmentSubstitute(idInField));\nif (idx < 0) throw new KettleStepException(\"Configured id field not in stream: \" + idInField);","typeGuard":null,"tryCatchPattern":"try { ... } catch (KettleStepException e) { if (e.getMessage().contains(\"InvalidIdField\")) { logError(\"Check id field setting: \" + meta.getIdInField()); } throw e; }","preventionTips":["Place the step after steps that could drop/rename the id field (e.g. Select values)","Cross-check step dialog settings against a row preview","Clear the id field setting if document _id is not needed"],"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"}