Skip to content

Commit 93d6923

Browse files
CR Comments
1 parent f87a5db commit 93d6923

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

docs/reference/ingest/ingest-node.asciidoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,9 +1075,10 @@ then it aborts the execution and leaves the array unmodified.
10751075
.Foreach Options
10761076
[options="header"]
10771077
|======
1078-
| Name | Required | Default | Description
1079-
| `field` | yes | - | The array field
1080-
| `processor` | yes | - | The processor to execute against each field
1078+
| Name | Required | Default | Description
1079+
| `field` | yes | - | The array field
1080+
| `processor` | yes | - | The processor to execute against each field
1081+
| `ignore_missing` | no | false | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
10811082
|======
10821083

10831084
Assume the following document:

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorFactoryTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public void testCreate() throws Exception {
4646
assertThat(forEachProcessor, Matchers.notNullValue());
4747
assertThat(forEachProcessor.getField(), equalTo("_field"));
4848
assertThat(forEachProcessor.getProcessor(), Matchers.sameInstance(processor));
49+
assertFalse(forEachProcessor.isIgnoreMissing());
4950
}
5051

5152
public void testSetIgnoreMissing() throws Exception {

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/ForEachProcessorTests.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.List;
2727
import java.util.Locale;
2828
import java.util.Map;
29-
import org.elasticsearch.ingest.AbstractProcessor;
3029
import org.elasticsearch.ingest.CompoundProcessor;
3130
import org.elasticsearch.ingest.IngestDocument;
3231
import org.elasticsearch.ingest.Processor;
@@ -277,22 +276,12 @@ public void testIgnoreMissing() throws Exception {
277276
IngestDocument originalIngestDocument = new IngestDocument(
278277
"_index", "_type", "_id", null, null, null, Collections.emptyMap()
279278
);
280-
IngestDocument ingestDocument = new IngestDocument(
281-
"_index", "_type", "_id", null, null, null, Collections.emptyMap()
282-
);
283-
ForEachProcessor processor = new ForEachProcessor("_tag", "_ingest._value", new AbstractProcessor("noop") {
284-
@Override
285-
public void execute(final IngestDocument ingestDocument) {
286-
throw new IllegalStateException("Should not run");
287-
}
288-
289-
@Override
290-
public String getType() {
291-
return null;
292-
}
293-
}, true);
279+
IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
280+
TestProcessor testProcessor = new TestProcessor(doc -> {});
281+
ForEachProcessor processor = new ForEachProcessor("_tag", "_ingest._value", testProcessor, true);
294282
processor.execute(ingestDocument);
295283
assertIngestDocument(originalIngestDocument, ingestDocument);
284+
assertThat(testProcessor.getInvokedCounter(), equalTo(0));
296285
}
297286

298287
}

0 commit comments

Comments
 (0)