# Two fields share the same name and type, how to combine them into 1 field?

**URL:** <https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229>\
**Category:** Logstash\
**Created:** [June 4, 2019, 4:32pm UTC](https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229 "2019-06-04T16:32:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![austin0918](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@austin0918](https://discuss.elastic.co/u/austin0918)\
**Post date:** [June 4, 2019, 4:32pm UTC](https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229/1 "2019-06-04T16:32:18Z")

</div>

Hi guys, I have two fields share the same name and type in an index, one is generated due to a kv{} filter, the second one is generated due to mutate {add\_field =\> {"Classification" =\> ""}} filter. Is there a way to combine them together?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/e/cefa99d1c84cbcd863a02879d9e438ec4bdefcf1.png)

When I do a search, the value presents in the two Classification field.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/5/c555a9d1ea729fba37025ad04c0c6e86a12a0d13.png)

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 4, 2019, 5:13pm UTC](https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229/2 "2019-06-04T17:13:56Z")

</div>

The only way I can think of that that could happen is that the field derived from the kv filter actually has a leading or trailing space in the field name, so it is actually called "Classificiation " rather than "Classification". If that is the case then a trim\_key option to the kv filter might help.

---

<div class="post-metadata">

**Author:** ![austin0918](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@austin0918](https://discuss.elastic.co/u/austin0918)\
**Post date:** [June 4, 2019, 5:16pm UTC](https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229/3 "2019-06-04T17:16:07Z")

</div>

Thank you Badger. I'll give it a try and let you know.

---

<div class="post-metadata">

**Author:** ![austin0918](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@austin0918](https://discuss.elastic.co/u/austin0918)\
**Post date:** [June 4, 2019, 5:28pm UTC](https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229/4 "2019-06-04T17:28:32Z")

</div>

Thank you again Badger. You're right. There is a leading space in the field name and trim\_key did magic. 🙂

---

<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:** [July 2, 2019, 5:28pm UTC](https://discuss.elastic.co/t/two-fields-share-the-same-name-and-type-how-to-combine-them-into-1-field/184229/5 "2019-07-02T17:28:36Z")

</div>

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