# Issue using logstash-input-jdbc to load mongo data

**URL:** <https://discuss.elastic.co/t/issue-using-logstash-input-jdbc-to-load-mongo-data/174914>\
**Category:** Logstash\
**Created:** [April 2, 2019, 6:19am UTC](https://discuss.elastic.co/t/issue-using-logstash-input-jdbc-to-load-mongo-data/174914 "2019-04-02T06:19:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![supritha](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@supritha](https://discuss.elastic.co/u/supritha)\
**Post date:** [April 2, 2019, 6:19am UTC](https://discuss.elastic.co/t/issue-using-logstash-input-jdbc-to-load-mongo-data/174914/1 "2019-04-02T06:19:31Z")

</div>

Hello, I'm using logstash to load MongoDB data to elasticsearch. I get MongoDB data inside the map field (inside source). I want data to be part of the source, not in a separate field.  
I used db.collection.find() statement and I'm getting documents as,  
{  
"\_index": "test",  
"\_type": "doc",  
"\_id": "wxma3GkBX1wUOA268XBA",  
"\_score": 1,  
"\_source": {  
"map": {  
"\_id": "5b534ae2e4b0671367e2e3ce",  
"total": 247,  
"status": active,  
"dateModified": 1553585121902,  
},  
"@timestamp": "2019-04-02T05:52:14.923Z",  
"@version": "1"  
}  
}

I want it as :  
{  
"\_index": "test",  
"\_type": "doc",  
"\_id": "wxma3GkBX1wUOA268XBA",  
"\_score": 1,  
"\_source": {  
"\_id": "5b534ae2e4b0671367e2e3ce",  
"total": 247,  
"status": active,  
"dateModified": 1553585121902,  
"@timestamp": "2019-04-02T05:52:14.923Z",  
"@version": "1"  
}  
}

---

<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:** [April 2, 2019, 1:29pm UTC](https://discuss.elastic.co/t/issue-using-logstash-input-jdbc-to-load-mongo-data/174914/2 "2019-04-02T13:29:45Z")

</div>

If you want to move the fields of "map" to the top level you can use ruby

```
    ruby {
        code => '
            m = event.remove("map")
            m.each { |k, v|
                event.set(k, v)
            }
        '
    }
```

---

<div class="post-metadata">

**Author:** ![supritha](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@supritha](https://discuss.elastic.co/u/supritha)\
**Post date:** [April 3, 2019, 4:09am UTC](https://discuss.elastic.co/t/issue-using-logstash-input-jdbc-to-load-mongo-data/174914/3 "2019-04-03T04:09:01Z")

</div>

Thank you 🙂 Issue has been resolved .

---

<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:** [May 1, 2019, 4:09am UTC](https://discuss.elastic.co/t/issue-using-logstash-input-jdbc-to-load-mongo-data/174914/4 "2019-05-01T04:09:02Z")

</div>

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