# Logstash/JBDC for ES when using nested attributes?

**URL:** <https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130>\
**Category:** Logstash\
**Created:** [April 2, 2016, 11:22am UTC](https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130 "2016-04-02T11:22:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenSeb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benseb/32/8714_2.png) [@BenSeb](https://discuss.elastic.co/u/BenSeb)\
**Post date:** [April 2, 2016, 11:22am UTC](https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130/1 "2016-04-02T11:22:43Z")

</div>

Hi

We wish to index physical events as documents. Each event will have multiple attributes, such as artists who are attending, and dates.

We're migrating from Sphinx, and to deal with this, we produced a mysql query which produced a single row, with some columns containing the attributes, eg:

|id |name | artists |  
|001 | event 1 | artist1 artist2 artist3 |  
|002 | event 2 | artist1 artist4 artist9 |

Could someone point me in the correct direction for doing this with Logstash/ES? I can replicate the same layout and it will perform a search query, but I want to be able to use filters, etc to pull out all 'events with artist 1' for example so I presume I need to nest those artists within the event? Whats the best way to do this using Logstash+ JDBC?

Many thanks

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 2, 2016, 2:46pm UTC](https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130/2 "2016-04-02T14:46:04Z")

</div>

I think the best option would be to do a 1:1 mapping of RDBMS row to ES documents, i.e. turn the first row above into this document:

```auto
{
  "id": 1,
  "name": "event 1",
  "artist": [
    "artist1",
    "artist2",
    "artist3"
  ]
}

```

To split the `artists` field produced by Logstash's jdbc input you can use the mutate filter's split option.

---

<div class="post-metadata">

**Author:** ![BenSeb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benseb/32/8714_2.png) [@BenSeb](https://discuss.elastic.co/u/BenSeb)\
**Post date:** [April 2, 2016, 3:22pm UTC](https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130/3 "2016-04-02T15:22:56Z")

</div>

Ah that looks promising, thanks. Do the plugins needs installing seperately?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 2, 2016, 5:54pm UTC](https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130/4 "2016-04-02T17:54:37Z")

</div>

Some do, some are core plugins that are installed by default. The mutate filter is definitely a core plugin but I'm not sure about the jdbc input.

---

<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 6, 2017, 5:04am UTC](https://discuss.elastic.co/t/logstash-jbdc-for-es-when-using-nested-attributes/46130/5 "2017-07-06T05:04:16Z")

</div>


