# Configure Logstash to create an Elasticsearch document with nested arrays

**URL:** <https://discuss.elastic.co/t/configure-logstash-to-create-an-elasticsearch-document-with-nested-arrays/96979>\
**Category:** Logstash\
**Created:** [August 14, 2017, 2:24pm UTC](https://discuss.elastic.co/t/configure-logstash-to-create-an-elasticsearch-document-with-nested-arrays/96979 "2017-08-14T14:24:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricPSU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericpsu/32/21110_2.png) [@EricPSU](https://discuss.elastic.co/u/EricPSU)\
**Post date:** [August 14, 2017, 2:24pm UTC](https://discuss.elastic.co/t/configure-logstash-to-create-an-elasticsearch-document-with-nested-arrays/96979/1 "2017-08-14T14:24:17Z")

</div>

I'm indexing my PostgreSQL data for Elasticsearch using the Logstash JDBC Input Plugin. I have two tables called `REQUEST` and `ASSIGNMENT` listed below.

How can I use Logstash to index the two tables into one Elasticsearch document of type `REQUEST` with a nested arrays for all child `ASSIGNMENT` records? Is Grok something that could help me out?

```
Table: REQUEST

REQUEST_ID | POC
---------- | ----------------
1234 | Jon Snow
1256 | Tyrion Lannister

Table: ASSIGNMENT

ASSIGN_ID | REQUEST_ID | STATUS | CREATED
--------- | ---------- | ------- | ----------
2345 | 1234 | New | 2017-01-06
2364 | 1234 | Working | 2017-03-12
2399 | 1234 | Working | 2017-05-20
5736 | 1256 | New | 2017-06-28

```

This is what I want my Elasticsearch document to look like. It is a sample of the \_source value of the search result:

```
"_source": {
  "request_id": "1234",
  "poc": "Jon Snow",
  "assignments": [
    {
      "assign_id": "2345",
      "status": "New",
      "created": "2017-01-06"
    },
    {
      "assign_id": "2364",
      "status": "Working",
      "created": "2017-03-12"
    },
    {
      "assign_id": "2399",
      "status": "Working",
      "created": "2017-05-20"
    }
  ]
}
```

---

<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:** [September 11, 2017, 2:24pm UTC](https://discuss.elastic.co/t/configure-logstash-to-create-an-elasticsearch-document-with-nested-arrays/96979/2 "2017-09-11T14:24:32Z")

</div>

Closed on September 11, 2017, 2:24pm UTC

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