# Can we add pattern matching in document\_id while updating?

**URL:** <https://discuss.elastic.co/t/can-we-add-pattern-matching-in-document-id-while-updating/92899>\
**Category:** Logstash\
**Created:** [July 12, 2017, 11:46pm UTC](https://discuss.elastic.co/t/can-we-add-pattern-matching-in-document-id-while-updating/92899 "2017-07-12T23:46:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g\_dev](https://avatars.discourse-cdn.com/v4/letter/g/91b2a8/32.png) [@g\_dev](https://discuss.elastic.co/u/g_dev)\
**Post date:** [July 12, 2017, 11:46pm UTC](https://discuss.elastic.co/t/can-we-add-pattern-matching-in-document-id-while-updating/92899/1 "2017-07-12T23:46:33Z")

</div>

I want to add a new field to a document with document\_id like "{id}-{word}" by using logstash.  
I just know {id} part while updating. Is there a way can I do it either by update\_by\_query in script and how should I define document\_id in elasticsearch output plugin.

I'm trying to do:  
elasticsearch {  
index =\> "ib-node\_parsed-v1"  
document\_type =\> "parsed\_node"  
document\_id =\> {  
#not sure about this part, is there any way to achieve this. I want to do "Update all documents where document\_id is like {456789}-{word}  
grok {  
match =\> { "message" =\> "event.get('uniqueCollectionId')-%{GREEDYDATA}"  
} }  
action =\> "update"  
hosts =\> "ip:9200"  
script\_lang =\> "painless"  
script\_type =\> "inline"  
script =\> '  
ctx.\_source.brandingName = params.event.get("brandingName");  
ctx.\_source.globalCustomerId = params.event.get("globalCustomerId");  
'  
}

---

<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:** [August 9, 2017, 11:46pm UTC](https://discuss.elastic.co/t/can-we-add-pattern-matching-in-document-id-while-updating/92899/2 "2017-08-09T23:46:40Z")

</div>

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