# Ingest plugin context data

**URL:** <https://discuss.elastic.co/t/ingest-plugin-context-data/273788>\
**Category:** Elasticsearch\
**Created:** [May 24, 2021, 7:08am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788 "2021-05-24T07:08:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmalocic](https://avatars.discourse-cdn.com/v4/letter/n/e9a140/32.png) [@nmalocic](https://discuss.elastic.co/u/nmalocic)\
**Post date:** [May 24, 2021, 7:08am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/1 "2021-05-24T07:08:06Z")

</div>

Hi everyone,

I am building ingest plugin, and I was wondering if there is any way to know index, or pipeline name from plugin?

My idea is to enable users to have multiple configurations so this seems like easy solution.

Thanks,  
Nemanja

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 25, 2021, 10:28am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/2 "2021-05-25T10:28:55Z")

</div>

Can you elaborate a little bit more, where you would like to know index/pipeline within your plugin?

Thanks!

---

<div class="post-metadata">

**Author:** ![nmalocic](https://avatars.discourse-cdn.com/v4/letter/n/e9a140/32.png) [@nmalocic](https://discuss.elastic.co/u/nmalocic)\
**Post date:** [May 26, 2021, 10:12am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/3 "2021-05-26T10:12:19Z")

</div>

Hi @spinscale ,

I am not sure, my main goal is to be able to read different configuration files, based on some parameter that will be read from plugin. As far as I see same plugin code is executed for every registered pipeline, so my idea was that when document is processed there is context that tells me pipeline name or index name.  
That can be either in settings or some other params as far as I see exceute of parameter only takes IngestDocument as param:

```auto
    public NaturalLanguagePlugin(final Settings settings, final Path configPath) {
        this.config = ConfigurationParser.parseConfiguration(new Environment(settings, configPath));
    }

```

```auto
IngestDocument execute(IngestDocument ingestDocument) throws Exception;

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 26, 2021, 11:09am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/4 "2021-05-26T11:09:42Z")

</div>

Your `IngestPlugin` implements `Map<String, Processor.Factory> getProcessors(Processor.Parameters parameters)`. The trick would be to create a `Processor.Factory` [implementation](https://github.com/elastic/elasticsearch/blob/ddc3744b164507ac89475e2606c60e523b3bb578/server/src/main/java/org/elasticsearch/ingest/Processor.java#L75-L88) that takes the config as an argument and thus can pass it to the processor implementation.

---

<div class="post-metadata">

**Author:** ![nmalocic](https://avatars.discourse-cdn.com/v4/letter/n/e9a140/32.png) [@nmalocic](https://discuss.elastic.co/u/nmalocic)\
**Post date:** [May 26, 2021, 12:11pm UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/5 "2021-05-26T12:11:39Z")

</div>

Hi @spinscale ,

But my questions where in plugin could I read information about "index" or "pipeline".  
I see that Plugin takes Settings and Path, but not sure if these information's are available to us from plugin.

For example does [Parameters](https://github.com/elastic/elasticsearch/blob/ddc3744b164507ac89475e2606c60e523b3bb578/server/src/main/java/org/elasticsearch/ingest/Processor.java#L94-L147) class holds information about "index" that will hold the document, or pipeline name that is executed.

Nemanja

---

<div class="post-metadata">

**Author:** ![nmalocic](https://avatars.discourse-cdn.com/v4/letter/n/e9a140/32.png) [@nmalocic](https://discuss.elastic.co/u/nmalocic)\
**Post date:** [June 1, 2021, 6:55am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/6 "2021-06-01T06:55:42Z")

</div>

Hi @spinscale ,

Is there any way of doing this, or should I stop dreaming.

Kind regards,  
Nemanja

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 1, 2021, 9:13am UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/7 "2021-06-01T09:13:23Z")

</div>

You probably need to invert your thinking a little, as the lifecycle of those classes is a bit different. A plugin gets created on node startup, and the only configuration it can read are settings from the configuration file. You could read those, when a a pipeline is created, by referring in the processor configuration when storing a pipeline to different settings.

Again, this is about passing down settings to a single processor instance and collect all information there, instead of passing them up to the plugin.

Hope that helps a little from an architecture point of view. Otherwise, please add more information.

Thanks!

---

<div class="post-metadata">

**Author:** ![nmalocic](https://avatars.discourse-cdn.com/v4/letter/n/e9a140/32.png) [@nmalocic](https://discuss.elastic.co/u/nmalocic)\
**Post date:** [June 1, 2021, 1:29pm UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/8 "2021-06-01T13:29:16Z")

</div>

Hi @spinscale,

I think I understand what you are saying, and workaround that I see is to add additional parameter when registering pipeline like this:

```auto
{
    "description": "ExpertAi processing API cloud",
    "processors": [
        {
            "cloud": {
                "field": "text",
                "target_field": "language",
                "config_name": "config1.yml"
            }
        }
    ]
}

```

I don't rly like this but this will let user to pick different configuration for different pipelines.

---

<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:** [June 29, 2021, 1:29pm UTC](https://discuss.elastic.co/t/ingest-plugin-context-data/273788/9 "2021-06-29T13:29:56Z")

</div>

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