# Ingest Plugin - Index new documents from within pipeline processor

**URL:** <https://discuss.elastic.co/t/ingest-plugin-index-new-documents-from-within-pipeline-processor/228075>\
**Category:** Elasticsearch\
**Created:** [April 15, 2020, 9:47am UTC](https://discuss.elastic.co/t/ingest-plugin-index-new-documents-from-within-pipeline-processor/228075 "2020-04-15T09:47:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpew](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mrpew](https://discuss.elastic.co/u/mrpew)\
**Post date:** [April 15, 2020, 9:47am UTC](https://discuss.elastic.co/t/ingest-plugin-index-new-documents-from-within-pipeline-processor/228075/1 "2020-04-15T09:47:22Z")

</div>

Heya!

Is there a way to create/index _new_ documents from within the context of a running pipeline processor?

Basically, I want to do this:

```auto
@Override
public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
    final String someValue = ingestDocument.getFieldValue("someField", String.class);
    if(something(someValue)){
        ingestDocument.appendFieldValue("someAdditionalField","someAdditionalValue");
    }else {
        HashMap<String, Object> newDocument = new HashMap<>();
        newDocument.put("myFoo","myBar");
        newDocument.put("answer", 42);
        someCoolApi.indexDocument("my-other-index", newDocument);
    }
    return ingestDocument;
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 13, 2020, 9:47am UTC](https://discuss.elastic.co/t/ingest-plugin-index-new-documents-from-within-pipeline-processor/228075/2 "2020-05-13T09:47:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
