# Set/Create field with query

**URL:** <https://discuss.elastic.co/t/set-create-field-with-query/133016>\
**Category:** Elasticsearch\
**Created:** [May 23, 2018, 3:24pm UTC](https://discuss.elastic.co/t/set-create-field-with-query/133016 "2018-05-23T15:24:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![skaldenmet](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@skaldenmet](https://discuss.elastic.co/u/skaldenmet)\
**Post date:** [May 23, 2018, 3:24pm UTC](https://discuss.elastic.co/t/set-create-field-with-query/133016/1 "2018-05-23T15:24:53Z")

</div>

Hey,

I am using the low level library in python to query all documents with a specific timestamp and want to add a new field to this documents with "script". However I cannot get it working. I just get the error:  
SyntaxError: non-keyword arg after keyword arg

```
    enrich_scan = scan(es, index='logstash-*', doc_type='etc',
            {"script" :{"source": "ctx._source.dns_alias = dns['_source']['dns_alias']"}
             },
              query={"query" :
                   {"bool" :
                       {"must" :
                               {"match" :
                                       { "@timestamp" : dns['_source']['@timestamp'] }
                               },
                        "must" :
                               {"match" :
                                       { "asset" : dns['_source']['asset'] }
                               }
                       }
                   }
        }
)
```

---

<div class="post-metadata">

**Author:** ![skaldenmet](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@skaldenmet](https://discuss.elastic.co/u/skaldenmet)\
**Post date:** [June 12, 2018, 7:53am UTC](https://discuss.elastic.co/t/set-create-field-with-query/133016/2 "2018-06-12T07:53:32Z")

</div>

Fixed it with the line:  
"script" : { "inline" : "ctx.\_source.dns\_alias='{!s}'".format(dns\_alias)}}

---

<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 10, 2018, 7:53am UTC](https://discuss.elastic.co/t/set-create-field-with-query/133016/3 "2018-07-10T07:53:33Z")

</div>

Closed on July 10, 2018, 7:53am UTC

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