# Nested List Ingest Pipeline

**URL:** <https://discuss.elastic.co/t/nested-list-ingest-pipeline/320504>\
**Category:** Elasticsearch\
**Tags:** painless, ingest-pipeline\
**Created:** [December 5, 2022, 9:40pm UTC](https://discuss.elastic.co/t/nested-list-ingest-pipeline/320504 "2022-12-05T21:40:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwissm1](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dwissm1](https://discuss.elastic.co/u/dwissm1)\
**Post date:** [December 5, 2022, 9:40pm UTC](https://discuss.elastic.co/t/nested-list-ingest-pipeline/320504/1 "2022-12-05T21:40:17Z")

</div>

Hey Folks.

I have a nested list inside of a list (obs - below) in some data from my tempest weather station. I want to split out the csv and I have the field names. I tried a foreach and a foreach with an append... no joy. Im pretty awful at painless. Anyone see a straight forward way to do this that I am missing?

Its quite simple to do in python outside elastic but want to figure out how to do it.

Elasticsearch: 8.5.2

Sample:

```auto
    {
        "serial_number": "ST-00000512",
        "type": "obs_st",
        "hub_sn": "HB-00013030",
        "obs": [
            [1588948614,0.18,0.22,0.27,144,6,1017.57,22.37,50.26,328,0.03,3,0.000000,0,0,0,2.410,1]
        ],
        "firmware_revision": 129
    }

```

---

<div class="post-metadata">

**Author:** ![dwissm1](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dwissm1](https://discuss.elastic.co/u/dwissm1)\
**Post date:** [December 14, 2022, 1:01am UTC](https://discuss.elastic.co/t/nested-list-ingest-pipeline/320504/2 "2022-12-14T01:01:14Z")

</div>

Figured it out… was not pretty and used a combo of painless to reassign the value to a string and then used CSV to break it out.

```auto
{
            "script": {
                "lang": "painless",
                "source": "ctx.temp_obs = ctx.obs[0].toString();"
            }
        },
        {
            "csv": {
                "field": "temp_obs",
                "target_fields": [
                    "observations.station_timestamp",
                    "observations.wind_lull",
                    "observations.wind_avg",
                    "observations.wind_gust",
                    "observations.wind_direction",
                    "observations.wind_sample_interval",
                    "observations.station_pressure",
                    "observations.air_temperature",
                    "observations.relative_humidity",
                    "observations.illuminance_lux",
                    "observations.uv_index",
                    "observations.solar_radiation",
                    "observations.rain_over_previous_min",
                    "observations.precipitation_type",
                    "observations.lightning_strike_avg_dist",
                    "observations.lightning_strike_count",
                    "observations.battery_volts",
                    "observations.report_interval"
                ],
                "separator": ",",
                "trim": true
            }
      

```

---

<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:** [January 11, 2023, 1:01am UTC](https://discuss.elastic.co/t/nested-list-ingest-pipeline/320504/3 "2023-01-11T01:01:40Z")

</div>

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