# 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:** 4

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [December 5, 2016, 8:14pm UTC](https://discuss.elastic.co/t/how-to-remove-subfield-using-ruby/68072/4 "2016-12-05T20:14:19Z")

</div>

event.to\_hash returns a hash that might contain other hashes, i.e. if the `outputdata` field has subfields you can access its hash via `event['outputdata']`. Something like this should work:

```nohighlight
event['outputdata'].keys.each { |k|
  event['outputdata'].remove(k) if k.start_with?('ID')
}

```

---

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