# Adding extra fields on reindexing

**URL:** <https://discuss.elastic.co/t/adding-extra-fields-on-reindexing/127708>\
**Category:** Elasticsearch\
**Created:** [April 12, 2018, 1:09am UTC](https://discuss.elastic.co/t/adding-extra-fields-on-reindexing/127708 "2018-04-12T01:09:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep\_Gowda](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@Pradeep\_Gowda](https://discuss.elastic.co/u/Pradeep_Gowda)\
**Post date:** [April 12, 2018, 1:09am UTC](https://discuss.elastic.co/t/adding-extra-fields-on-reindexing/127708/1 "2018-04-12T01:09:20Z")

</div>

Hi,  
How can I add extra filed's when I reindex the documents using Java API?

I tried below code and it doesn't work and fails with below exception

```
                Map<String, Object> params = new HashMap<>();
                params.put("newField", "test");
                ReindexRequestBuilder builder = ReindexAction.INSTANCE.newRequestBuilder(store.getClient()).source(sourceIndex)
                        .destination(destIndex);
                builder.destination().setVersionType(VersionType.EXTERNAL);
                builder.script(
                        new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "ctx.newfiled = newField",
                                params));
                BulkByScrollResponse bulkByScrollResponse = builder.execute().actionGet();

```

CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max\_compilations\_per\_minute] setting

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [April 12, 2018, 6:02am UTC](https://discuss.elastic.co/t/adding-extra-fields-on-reindexing/127708/2 "2018-04-12T06:02:32Z")

</div>

You can try to increase the `script.max_compilations_per_minute` setting and see if this helps your reindexing.

```
PUT /_cluster/settings
{
    "transient" : {
        "script.max_compilations_per_minute" : "2000/m"
    }
}

```

After the reindexing is done, you can set it back to its previous value

```
PUT /_cluster/settings
{
    "transient" : {
        "script.max_compilations_per_minute" : "15/m"
    }
}
```

---

<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 10, 2018, 6:02am UTC](https://discuss.elastic.co/t/adding-extra-fields-on-reindexing/127708/3 "2018-05-10T06:02:36Z")

</div>

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