# How to change "type" keyword in clone plugin

**URL:** https://discuss.elastic.co/t/how-to-change-type-keyword-in-clone-plugin/274499
**Category:** Logstash
**Created:** [May 31, 2021, 12:18pm UTC](https://discuss.elastic.co/t/how-to-change-type-keyword-in-clone-plugin/274499 "2021-05-31T12:18:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)
#### Post date: [May 31, 2021, 12:18pm UTC](https://discuss.elastic.co/t/how-to-change-type-keyword-in-clone-plugin/274499/1 "2021-05-31T12:18:27Z")

</div>

clone plugin default use "type" keyword. In my logstash configuration I use multiple times "type" keyword and now i need to add clone filter plugin in my logstash configuration.  
How can i use this plugin without using "type" keyword ? Its ok to use keyword but not same with "type". My aim is like below

```auto
filter {
  clone {
    clones => ["cloned"]
  }
  if [new_type] == "cloned" {
    # this filter
  } else {
    # that filter
  }
}

output {
  if [new_type] == "cloned" {
    elasticsearch {
      ... index2 ...
    }
  } else {
    elasticsearch {
      ... index1 ...
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [May 31, 2021, 2:29pm UTC](https://discuss.elastic.co/t/how-to-change-type-keyword-in-clone-plugin/274499/2 "2021-05-31T14:29:38Z")

</div>

The clone filter [unconditionally](https://github.com/logstash-plugins/logstash-filter-clone/blob/b430084f7876805f2ad9074f955c54542c56d225/lib/logstash/filters/clone.rb#L49) sets the type field. If you are already using that then you would need to do something like

```
mutate { rename => { "type" => "oldtype" } }
clone { ... }
mutate { rename => { "type" => "newtype" } }
mutate { rename => { "oldtype" => "type" } }
```

---

<div class="post-metadata">

### Author: ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)
#### Post date: [May 31, 2021, 3:14pm UTC](https://discuss.elastic.co/t/how-to-change-type-keyword-in-clone-plugin/274499/3 "2021-05-31T15:14:50Z")

</div>

I have tried your answer like below;

```auto
filter {
  mutate { rename => { "type" => "new_type" } }
  clone {
    clones => ["cloned"]
  }
  if [new_type] == "cloned" {
     # There are some operation like 
     mutate {
         replace => { type => "first_type"} 
     }
     if ... {
         mutate {
            replace => { type => "second_type"} 
        }
     }
     ....
  } else {
     # There are some operation like 
     mutate {
         replace => { type => "first_type"} 
     }
     if ... {
         mutate {
            replace => { type => "second_type"} 
        }
     }
     ....
  }
}

output {
  if [new_type] == "cloned" {
      stdout {
          codec => rubydebug
      }
  }
}

```

When I run this I got nothing to see. That didn't solve. I can only see "type" in output.

---

<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 28, 2021, 3:15pm UTC](https://discuss.elastic.co/t/how-to-change-type-keyword-in-clone-plugin/274499/4 "2021-06-28T15:15:41Z")

</div>

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