diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java index 87da73cce129d..45f00a7435033 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/CsvProcessorTests.java @@ -209,6 +209,7 @@ private IngestDocument processDocument(String[] headers, String csv) throws Exce private IngestDocument processDocument(String[] headers, String csv, boolean trim) throws Exception { IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); + Arrays.stream(headers).filter(ingestDocument::hasField).forEach(ingestDocument::removeField); String fieldName = RandomDocumentPicks.addRandomField(random(), ingestDocument, csv); char quoteChar = quote.isEmpty() ? '"' : quote.charAt(0);