# Inserting into the same index

**URL:** <https://discuss.elastic.co/t/inserting-into-the-same-index/40112>\
**Category:** Logstash\
**Created:** [January 26, 2016, 11:37am UTC](https://discuss.elastic.co/t/inserting-into-the-same-index/40112 "2016-01-26T11:37:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sreevatsa\_Vadiraj](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@Sreevatsa\_Vadiraj](https://discuss.elastic.co/u/Sreevatsa_Vadiraj)\
**Post date:** [January 26, 2016, 11:37am UTC](https://discuss.elastic.co/t/inserting-into-the-same-index/40112/1 "2016-01-26T11:37:05Z")

</div>

This is my logstash config file:  
input {  
jdbc {  
jdbc\_driver\_library =\> "/home/vatsa/logstash/mysql-connector-java-5.1.38-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/LC"  
jdbc\_user =\> "root"  
jdbc\_password =\> ""

```
statement => "select * from test where ID<=45000"

```

}  
}  
output {  
elasticsearch {

```
    index => "det"
    document_type => "contact"
    document_id => "%{ID}"
    hosts => "localhost:9200"
}

```

}  
and i run it using , logstash/bin/logstash -f /home/vatsa/logs/conts-jdbc.conf

Next time,if i change the query to ID\>45000 AND ID\<=90000 and i run it ,the data in previous index gets replaced by the data.  
How do i add this data to the data present in the previous index?

---

<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:** [July 6, 2017, 5:14am UTC](https://discuss.elastic.co/t/inserting-into-the-same-index/40112/2 "2017-07-06T05:14:19Z")

</div>


