# Can logstash add array field to elasticsearch?

**URL:** https://discuss.elastic.co/t/can-logstash-add-array-field-to-elasticsearch/249202
**Category:** Logstash
**Created:** [September 19, 2020, 7:09am UTC](https://discuss.elastic.co/t/can-logstash-add-array-field-to-elasticsearch/249202 "2020-09-19T07:09:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![recordable542](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/recordable542/32/69082_2.png) [@recordable542](https://discuss.elastic.co/u/recordable542)
#### Post date: [September 19, 2020, 7:09am UTC](https://discuss.elastic.co/t/can-logstash-add-array-field-to-elasticsearch/249202/1 "2020-09-19T07:09:58Z")

</div>

## My Environment

- mysql
- logstash (with jdbc plugin) 7.8.0
- elasticsearch 7.6.2

## pipeline.yaml

```auto
...
statement => "SELECT id, name, location1, location2 FROM users;"
...

```

I have `location1` and `location2` column in mysql `users` table. I want to make them to one array field like...

```auto
statement => "SELECT id, name, location1, location2 FROM users;"

    filter {
        mutate {
            add_field => {
              "location" => "[%{location1}, %{location2}]"
            }
        }
    }

```

so that I can later query all users who ...  
(location1 == "NY" or location2 == "NY") or (location1 == "NJ" or location2 == "NJ")

```auto
query: {"terms": {"location": ["NY", "NJ"]}}

```

---

<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: [October 17, 2020, 7:10am UTC](https://discuss.elastic.co/t/can-logstash-add-array-field-to-elasticsearch/249202/2 "2020-10-17T07:10:06Z")

</div>

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