# Restheart issue with \_embedded http\_poller

**URL:** <https://discuss.elastic.co/t/restheart-issue-with-embedded-http-poller/115663>\
**Category:** Logstash\
**Created:** [January 16, 2018, 8:26am UTC](https://discuss.elastic.co/t/restheart-issue-with-embedded-http-poller/115663 "2018-01-16T08:26:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahajan344](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@mahajan344](https://discuss.elastic.co/u/mahajan344)\
**Post date:** [January 16, 2018, 8:26am UTC](https://discuss.elastic.co/t/restheart-issue-with-embedded-http-poller/115663/1 "2018-01-16T08:26:07Z")

</div>

Hi,

I want to insert data from MongoDB to ElasticSearch using Logstash. Since there is no input plugin for MongoDB, I am using http\_poller for input plugin which will communicate with MongoDB http interface `restheart`.

Now I am able to communicate with MongoDB with restheart. Here is response

`http://localhost:8080/test/testing/`

and response is as below

```
{
    "_embedded": [
        {
            "_id": {
                "$oid": "5a5db987cd0cac4b8ee1c8b7"
            },
            "name": "hello"
        }
    ],
    "_id": "testing",
    "_returned": 1
}

```

here is my logstash pipeline

```
input {
  http_poller {
    urls => {
      test2 => {
        # Supports all options supported by ruby's Manticore HTTP client
        method => get
        user => "a"
        password => "a"
        url => "http://localhost:8080/test/testing/"
        headers => {
          Accept => "application/json"
        }
     }
    }
    request_timeout => 60
    # Supports "cron", "every", "at" and "in" schedules by rufus scheduler
    schedule => { cron => "* * * * *"}
    codec => "json"
    # A hash of request metadata info (timing, response headers, etc.) will be sent here
    # metadata_target => "http_poller_metadata"
  }
}

filter {
		mutate {
				rename => { "[_id]" => "[mongo_id]" }
			   }
		}

output {
elasticsearch {
    hosts => 'http://localhost:9200'
    index => 'mongodbpoller'
    codec => json
    doc_as_upsert => true
    document_id => "%{[mongo_id][$oid]}"	

 }
  # stdout {
  # codec => rubydebug
  # }
}

```

Now problem is when i run pipeline , as main data is wrapped inside `_embedded` object . Logstash consider `_embedded` as data and inserts it as whole document.

How can I only insert

```
{
            "_id": "5a5db987cd0cac4b8ee1c8b7",
            "name": "hello"
        }
```

---

<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 13, 2018, 8:26am UTC](https://discuss.elastic.co/t/restheart-issue-with-embedded-http-poller/115663/2 "2018-02-13T08:26:21Z")

</div>

Closed on February 13, 2018, 8:26am UTC

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