# How can i add two fields which contains string value and store it in a new field

**URL:** <https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872>\
**Category:** Logstash\
**Created:** [May 27, 2019, 9:29am UTC](https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872 "2019-05-27T09:29:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishnu\_mk](https://avatars.discourse-cdn.com/v4/letter/v/71c47a/32.png) [@Vishnu\_mk](https://discuss.elastic.co/u/Vishnu_mk)\
**Post date:** [May 27, 2019, 9:29am UTC](https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872/1 "2019-05-27T09:29:22Z")

</div>

For ex:  
name: Vishnu  
surname\_filed : mk

I want a to combine this to filed and in a new field

Name: Vishnu mk

---

<div class="post-metadata">

**Author:** ![logger](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@logger](https://discuss.elastic.co/u/logger)\
**Post date:** [May 27, 2019, 10:14am UTC](https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872/2 "2019-05-27T10:14:25Z")

</div>

> filter {  
> mutate {  
> add\_field =\> { "new\_field" =\> "%{name} %{surname}" }  
> }  
> }

this should work. or you look at the mutate filter and have a look at the great options. maybe there is something thats suites you better. like the merge option.

> **[Mutate filter plugin | Logstash Reference \[8.11\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html)**

---

<div class="post-metadata">

**Author:** ![Vishnu\_mk](https://avatars.discourse-cdn.com/v4/letter/v/71c47a/32.png) [@Vishnu\_mk](https://discuss.elastic.co/u/Vishnu_mk)\
**Post date:** [May 27, 2019, 11:05am UTC](https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872/3 "2019-05-27T11:05:22Z")

</div>

How can i add field in ingest pipeline:  
PUT _ingest/pipeline/abc7  
{  
"description" : "fscrawler res2",  
"processors" : [  
{  
"grok": {  
"field": "content",  
"patterns": ["(^|\s)(?(\+\d{1,3}[-]?)?\d{10})($|\s)"]  
}  
},  
{  
"grok": {  
"field": "path.virtual",  
"patterns": ["%{DATA:name1} %{DATA:surname}\_%{GREEDYDATA:remaining}"]  
}  
}

]

This is my code i want to murge name1 and surname filed

---

<div class="post-metadata">

**Author:** ![logger](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@logger](https://discuss.elastic.co/u/logger)\
**Post date:** [May 27, 2019, 12:20pm UTC](https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872/4 "2019-05-27T12:20:24Z")

</div>

You are talking about elasticsearch and not logstash.

But have a look at this.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/accessing-data-in-pipelines.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/accessing-data-in-pipelines.html)

there you can access fields with the set parameter.

---

<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 24, 2019, 12:20pm UTC](https://discuss.elastic.co/t/how-can-i-add-two-fields-which-contains-string-value-and-store-it-in-a-new-field/182872/5 "2019-06-24T12:20:36Z")

</div>

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