# Merging JSON files

**URL:** <https://discuss.elastic.co/t/merging-json-files/108626>\
**Category:** Logstash\
**Created:** [November 22, 2017, 12:03am UTC](https://discuss.elastic.co/t/merging-json-files/108626 "2017-11-22T00:03:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NPNP](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/npnp/32/24533_2.png) [@NPNP](https://discuss.elastic.co/u/NPNP)\
**Post date:** [November 22, 2017, 12:03am UTC](https://discuss.elastic.co/t/merging-json-files/108626/1 "2017-11-22T00:03:46Z")

</div>

Hello everyone,

100% newbie here. Thank you for your patience.

I'm trying to merge two simple json files under certain condition. Is that possible? Any direction is useful.

JSON\_1

```
{
    "name_1" : "John",
    "age_1": 25
}

```

JSON\_2

```
{
    "name_2" : "John",
    "company" : "xyz"
}

```

So, if "name\_1" is equal to "name\_2", I would like to merge JSON files and change "name\_1" and "name\_2" to just "name". Output would be:

```
{
     "name": "John",
     "age_1": 25,
     "company" : "xyz"
}

```

Merging JSONs with JavaScript is easy, but I would like to do it with Elastisearch too.

Any help is appreciated. Thank you very much.

---

<div class="post-metadata">

**Author:** ![NPNP](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/npnp/32/24533_2.png) [@NPNP](https://discuss.elastic.co/u/NPNP)\
**Post date:** [November 22, 2017, 1:59am UTC](https://discuss.elastic.co/t/merging-json-files/108626/2 "2017-11-22T01:59:21Z")

</div>

I just found this question answered. I'm trying to figure out if I can combine fields in Kibana.

> [@How to combine two file types in logstash](https://discuss.elastic.co/t/how-to-combine-two-file-types-in-logstash/41278):
>
> I have two different file types as below file { path =\> "/opt/logsl/test\_log.log\*" #start\_position =\> "beginning" type =\> "test1" } file { path =\> "/opt/lookups/testcsv.csv" start\_position =\> "beginning" type =\> "test2" } Both types have common field values. I need to match those fields and map the corresponding values. (similar to outer join) something like below snippet if test2.ServerIP\_1 == test1.ServerIP { add\_field =\> { "city\_ip" =\>test1. ServerName\_1} } can anyone help…

I have JSON files loaded under the same index. Two different types under the same index to be precise. I loaded both via logstash. I would need to merge fields somehow. Any direction is appreciated.

---

<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 20, 2017, 1:59am UTC](https://discuss.elastic.co/t/merging-json-files/108626/3 "2017-12-20T01:59:40Z")

</div>

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