# Set and persist elasticsearch index mappings for couchdb\_changes input from logstash

**URL:** <https://discuss.elastic.co/t/set-and-persist-elasticsearch-index-mappings-for-couchdb-changes-input-from-logstash/220357>\
**Category:** Logstash\
**Created:** [February 21, 2020, 12:37pm UTC](https://discuss.elastic.co/t/set-and-persist-elasticsearch-index-mappings-for-couchdb-changes-input-from-logstash/220357 "2020-02-21T12:37:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![omunyari](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@omunyari](https://discuss.elastic.co/u/omunyari)\
**Post date:** [February 21, 2020, 12:37pm UTC](https://discuss.elastic.co/t/set-and-persist-elasticsearch-index-mappings-for-couchdb-changes-input-from-logstash/220357/1 "2020-02-21T12:37:11Z")

</div>

I am currently populating an elasticsearch index from logstash using the couchdb\_changes input plugin with the following configuration.  
input {  
couchdb\_changes {  
type =\> "meet"  
db =\> "my\_db"  
host =\> "127.0.0.1"  
port =\> 5984  
initial\_sequence =\> 0  
keep\_revision =\> true  
}  
}

filter {  
if [@metadata][action] == "delete" {  
mutate {  
add\_field =\> {"elastic\_action" =\> "delete"}  
}  
} else {  
mutate {  
add\_field =\> {"elastic\_action" =\> "index"}  
}  
}  
}

output {  
elasticsearch {  
index =\> "my-index"  
document\_id =\> "%{[@metadata][\_id]}"  
action =\> "%{elastic\_action}"  
}  
}  
I understand that the event from logstash is of the form {doc:{}, doc\_as\_upsert:{}, @timestamp, @version}. I have configured mappings in my-index according to the field structure of my couchdb documents more especially to cater for arrays of objects by setting the type to nested. When I run logstash, however, the mappings in my-index seem to be overwritten and the "type": "nested" setting completely removed from the fields that I would like to set to this setting. As such I can query the index the way I would like. Any pointers on what I am doing wrong would be much appreciated.

---

<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:** [March 20, 2020, 12:37pm UTC](https://discuss.elastic.co/t/set-and-persist-elasticsearch-index-mappings-for-couchdb-changes-input-from-logstash/220357/2 "2020-03-20T12:37:20Z")

</div>

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