# How to group all the values for a column into an array jdbc mysql

**URL:** <https://discuss.elastic.co/t/how-to-group-all-the-values-for-a-column-into-an-array-jdbc-mysql/33433>\
**Category:** Logstash\
**Created:** [October 31, 2015, 10:46am UTC](https://discuss.elastic.co/t/how-to-group-all-the-values-for-a-column-into-an-array-jdbc-mysql/33433 "2015-10-31T10:46:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clp](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@clp](https://discuss.elastic.co/u/clp)\
**Post date:** [October 31, 2015, 10:46am UTC](https://discuss.elastic.co/t/how-to-group-all-the-values-for-a-column-into-an-array-jdbc-mysql/33433/1 "2015-10-31T10:46:15Z")

</div>

Hi,

I am trying to import data from mysql to elasticsearch via logstash and i would like to know if it's possible to group all the values for a column into an array per id.

for example in mysql, results of query is

```
 '_id', 'name' , 'tag' 
'1', 'Reparer PC', 'tec'
'1', 'Reparer PC', 'Urgent'
'1', 'Reparer PC', 'jdbc'

```

and i would like to create a unique document like this in elasticsearch.

```
id:1, task.name: 'Reparer PC', task.tag { tec, Urgent, jdbc}

```

logstash configuration

```
input {
    jdbc {
        # Postgres jdbc connection string to our database, mydb
        jdbc_connection_string => "jdbc:mysql:// ****** :3306/demo_es"
        # The user we wish to execute our statement as
        jdbc_user => "admin"
        jdbc_password => " ******"
        # The path to our downloaded jdbc driver
        jdbc_driver_library => "/root/elasticsearch-jdbc-1.7.1.0/lib/mysql-connector-java-5.1.33.jar"
        # The name of the driver class for Postgresql
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        # our query
        statement => "select taches.id AS '_id', taches.name AS 'task.name', tags.name AS 'task.tags' from taches inner join tagstaches ON taches.id = tagstaches.idtache inner join tags on tagstaches.idtag = tags.idtags order by taches.id"
    }
}

output {
    elasticsearch {
        protocol => http
        index => "tasks"
        document_type => "task"
        document_id => "%{_id}"
        host => "localhost"
    }
}

```

This conf create a document where task.tag have only jdbc.

Thanks for your help,

Christophe

---

<div class="post-metadata">

**Author:** ![DaanCreemers](https://avatars.discourse-cdn.com/v4/letter/d/b5ac83/32.png) [@DaanCreemers](https://discuss.elastic.co/u/DaanCreemers)\
**Post date:** [June 15, 2016, 9:32am UTC](https://discuss.elastic.co/t/how-to-group-all-the-values-for-a-column-into-an-array-jdbc-mysql/33433/2 "2016-06-15T09:32:18Z")

</div>

Hi @clp,

Have you found a solution to your problem? I encountered the same problem where I would like to group the values for one column into an array per id.  
It would even be better if there was functionality which allows to create a nested object such that you can add multiple columns per id.

Regards,  
Daan

---

<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, 4:52am UTC](https://discuss.elastic.co/t/how-to-group-all-the-values-for-a-column-into-an-array-jdbc-mysql/33433/3 "2017-07-06T04:52:45Z")

</div>


