# How to remove subfield using ruby

**URL:** https://discuss.elastic.co/t/how-to-remove-subfield-using-ruby/68072
**Category:** Logstash
**Created:** [December 5, 2016, 4:57pm UTC](https://discuss.elastic.co/t/how-to-remove-subfield-using-ruby/68072 "2016-12-05T16:57:44Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![saisn](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@saisn](https://discuss.elastic.co/u/saisn)
#### Post date: [December 5, 2016, 8:51pm UTC](https://discuss.elastic.co/t/how-to-remove-subfield-using-ruby/68072/5 "2016-12-05T20:51:46Z")

</div>

Thank you . It worked but 'remove' is not available for hash instead using 'delete' as below worked.

code =\> "  
event['outputdata'].keys.each { |k|  
event['outputdata'].delete(k) if k.start\_with?('ID')  
}

Thanks

---

_[View the full topic](https://discuss.elastic.co/t/how-to-remove-subfield-using-ruby/68072)._
