# Add field by reindexing

**URL:** https://discuss.elastic.co/t/add-field-by-reindexing/108466
**Category:** Elasticsearch
**Created:** [November 20, 2017, 9:30pm UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466 "2017-11-20T21:30:41Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![prophoto](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@prophoto](https://discuss.elastic.co/u/prophoto)
#### Post date: [November 20, 2017, 9:30pm UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/1 "2017-11-20T21:30:41Z")

</div>

How do I add a field to my index? I wanted a day of week field for my dashboard in Kibana. I was able to add it in Logstash, but need to reindex to add it to past documents? I've read over the documentation but it doesn't have enough details or examples for someone just learning elastic search.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 21, 2017, 8:23am UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/2 "2017-11-21T08:23:32Z")

</div>

You should be able to use the [reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html#docs-reindex) together with a painless script. An example featuring a painless script similar to what you may be looking for is available [in this blog post](https://www.elastic.co/blog/using-painless-kibana-scripted-fields).

---

<div class="post-metadata">

### Author: ![prophoto](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@prophoto](https://discuss.elastic.co/u/prophoto)
#### Post date: [November 21, 2017, 10:18am UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/3 "2017-11-21T10:18:57Z")

</div>

I’m very new to Elasticsearch and need some more examples on how to use it, can you help?

---

<div class="post-metadata">

### Author: ![prophoto](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@prophoto](https://discuss.elastic.co/u/prophoto)
#### Post date: [November 23, 2017, 6:07pm UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/4 "2017-11-23T18:07:34Z")

</div>

bump

---

<div class="post-metadata">

### Author: ![prophoto](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@prophoto](https://discuss.elastic.co/u/prophoto)
#### Post date: [November 27, 2017, 2:02pm UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/5 "2017-11-27T14:02:39Z")

</div>

bump

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 27, 2017, 2:10pm UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/6 "2017-11-27T14:10:59Z")

</div>

What have you tried so far?

---

<div class="post-metadata">

### Author: ![prophoto](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@prophoto](https://discuss.elastic.co/u/prophoto)
#### Post date: [November 27, 2017, 10:47pm UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/7 "2017-11-27T22:47:31Z")

</div>

Not even sure how to start.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 28, 2017, 7:37am UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/8 "2017-11-28T07:37:57Z")

</div>

The example just before [this section of the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-reindex.html#reindex-from-remote), shows how you can use the reindex API together with an ingest pipeline.

[This section](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/pipeline.html) goes through how you create and store an ingest pipeline that you can use from your reindex API. In this pipeline you will want to use [a script processor](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/script-processor.html) to calculate the new fields.

In order to create the painless script, you can look at the date math example in [this blog post](https://www.elastic.co/blog/using-painless-kibana-scripted-fields) for inspiration.

---

<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: [December 26, 2017, 7:38am UTC](https://discuss.elastic.co/t/add-field-by-reindexing/108466/9 "2017-12-26T07:38:38Z")

</div>

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