# Concatenate a value of three fields in the a new filed

**URL:** <https://discuss.elastic.co/t/concatenate-a-value-of-three-fields-in-the-a-new-filed/115725>\
**Category:** Elasticsearch\
**Created:** [January 16, 2018, 1:46pm UTC](https://discuss.elastic.co/t/concatenate-a-value-of-three-fields-in-the-a-new-filed/115725 "2018-01-16T13:46:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marouane](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marouane/32/83858_2.png) [@marouane](https://discuss.elastic.co/u/marouane)\
**Post date:** [January 16, 2018, 1:46pm UTC](https://discuss.elastic.co/t/concatenate-a-value-of-three-fields-in-the-a-new-filed/115725/1 "2018-01-16T13:46:48Z")

</div>

Hello every one,  
I want to replace 3 fields that contains string(date) , string(time) and string(tz) by a new field with date type that contains (date+time+tz) converted.

```
{
"query":{
"bool":{
"must_not":{
"exists":{
"field":"new_date"
}
}
}
},
"script":{
"inline":"ctx._source.new_date = ctx._source.date + ctx._source.time + ctx._source.tz",
"lang":"groovy"
}
}

```

But before that how can i concatenate them because like this whay i have a scrpt exception?

This is what i have :

```
GET myindex/_search
{
  "query": {
  "match_all": {}
  }
}

"hits": {
"total": 148563278,
"max_score": 1,
"hits": [
  {
    "_index": "myindex",
    "_type": "mytype",
    "_id": "1",
    "_score": 1,
    "_source": {
      "date": "2016-06-30",
      "tz": "UTC",
      "time": "10:21:16",

```

I want to :  
add 2 other fields:

- field1 = date\_time\_tz\_str ( string : concatenation of 3 fields )
- field2 = date\_time\_tz ( timestamp ) conversion of field ( date\_time\_tz\_str)

Thank you for your help

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [January 19, 2018, 1:27pm UTC](https://discuss.elastic.co/t/concatenate-a-value-of-three-fields-in-the-a-new-filed/115725/2 "2018-01-19T13:27:36Z")

</div>

do you want to create a new field at index time or do you want to build a value for an existing doc at query time that you are querying?

---

<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:** [February 16, 2018, 1:33pm UTC](https://discuss.elastic.co/t/concatenate-a-value-of-three-fields-in-the-a-new-filed/115725/3 "2018-02-16T13:33:45Z")

</div>

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