# Array of objects in pipeline

**URL:** <https://discuss.elastic.co/t/array-of-objects-in-pipeline/234356>\
**Category:** Elasticsearch\
**Created:** [May 26, 2020, 2:38pm UTC](https://discuss.elastic.co/t/array-of-objects-in-pipeline/234356 "2020-05-26T14:38:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajsolanki](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajsolanki/32/86859_2.png) [@rajsolanki](https://discuss.elastic.co/u/rajsolanki)\
**Post date:** [May 26, 2020, 2:38pm UTC](https://discuss.elastic.co/t/array-of-objects-in-pipeline/234356/1 "2020-05-26T14:38:13Z")

</div>

Hi i m trying to write a pipeline to find a missing field in an array of objects. So this is what i wrote.

```
PUT _ingest/pipeline/header-missing
{
  "description": "header missing",
  "version": 1,
 "processors" : [
    {
      "script" : {
        "source": """
        for (item in ctx.request_headers) {
          item.field_lower = item.header1;
          if(ctx.item?.header1 == null){
            item.field = "raj"
          }
          
          }
        """
      }
    }
  ]
}

```

Here is my simulate

```
POST /_ingest/pipeline/header-missing/_simulate?verbose
{
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "request_headers": [
          {
            "header1": "one"
            
          },
          {
            "header2": "two"
            
          }
        ]
      }
    }
  ]
}

```

i think i m getting lost in finding value of an object. thus its printing "field " : "raj" on both fields. any help on what should i be doing ?

thanks

Raj

---

<div class="post-metadata">

**Author:** ![rajsolanki](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajsolanki/32/86859_2.png) [@rajsolanki](https://discuss.elastic.co/u/rajsolanki)\
**Post date:** [May 27, 2020, 3:39am UTC](https://discuss.elastic.co/t/array-of-objects-in-pipeline/234356/2 "2020-05-27T03:39:37Z")

</div>

am i trying something wrong ? I have tried

> ```
> "processor": {
> "set": {
> "field": "my_field",
> "value": "{{_ingest.header1._value}}"
>             
> }
> }
> 
> ```

just cant seem to figure this ☹ All i m trying is if field is missing set my custom field and if field is there extract value and assign it to my custom field .

---

<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:** [June 24, 2020, 3:39am UTC](https://discuss.elastic.co/t/array-of-objects-in-pipeline/234356/3 "2020-06-24T03:39:42Z")

</div>

Closed on June 24, 2020, 3:39am UTC

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