# How to create a scripted fields for data in two different indexes

**URL:** <https://discuss.elastic.co/t/how-to-create-a-scripted-fields-for-data-in-two-different-indexes/94667>\
**Category:** Kibana\
**Created:** [July 26, 2017, 4:45pm UTC](https://discuss.elastic.co/t/how-to-create-a-scripted-fields-for-data-in-two-different-indexes/94667 "2017-07-26T16:45:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepikakamalla](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Deepikakamalla](https://discuss.elastic.co/u/Deepikakamalla)\
**Post date:** [July 26, 2017, 4:45pm UTC](https://discuss.elastic.co/t/how-to-create-a-scripted-fields-for-data-in-two-different-indexes/94667/1 "2017-07-26T16:45:43Z")

</div>

Hi,

We have data stored in 2 different indexes,. say index1 and index2. Here, we have created the index pattern as index\*.  
The, index1 has a fieldname - 'val' for a particular month. and  
index2 also has a fieldname - 'val' for some other month. So, inorder to differentiate both the fields. we renamed index2 'val' field as "val2"., before pushing it to elasticsearch. Also, both fields are numeric datatype.

Now, we have 2 fields say 'val' and 'val2' in the index - 'index\*', and trying to create a scripted field as doc['val'].value + doc['val2'].value. But, while visualizing the data in metric visualization, we are getting "visualization error".  
Can someone suggest the solution for this...

Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [July 28, 2017, 6:23pm UTC](https://discuss.elastic.co/t/how-to-create-a-scripted-fields-for-data-in-two-different-indexes/94667/2 "2017-07-28T18:23:43Z")

</div>

Hi @Deepikakamalla,

As far as I can tell, that is not possible. Scripted-fields are submitted in the query to Elasticsearch, which hits only a single index.

I would continue this discussion in the Elasticsearch discuss channel ([https://discuss.elastic.co/c/elasticsearch](https://discuss.elastic.co/c/elasticsearch)), or perhaps open an enhancement request in the Elasticsearch repo. [https://github.com/elastic/elasticsearch/issues/new](https://github.com/elastic/elasticsearch/issues/new)

---

<div class="post-metadata">

**Author:** ![Deepikakamalla](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Deepikakamalla](https://discuss.elastic.co/u/Deepikakamalla)\
**Post date:** [July 29, 2017, 4:20am UTC](https://discuss.elastic.co/t/how-to-create-a-scripted-fields-for-data-in-two-different-indexes/94667/3 "2017-07-29T04:20:52Z")

</div>

Ok, thanks.

---

<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:** [August 26, 2017, 4:21am UTC](https://discuss.elastic.co/t/how-to-create-a-scripted-fields-for-data-in-two-different-indexes/94667/4 "2017-08-26T04:21:09Z")

</div>

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