# Replace the existing index with new data

**URL:** https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908
**Category:** Logstash
**Created:** [July 19, 2016, 5:44pm UTC](https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908 "2016-07-19T17:44:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![AnantPatil](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@AnantPatil](https://discuss.elastic.co/u/AnantPatil)
#### Post date: [July 19, 2016, 5:44pm UTC](https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908/1 "2016-07-19T17:44:01Z")

</div>

Hi,

I have the index name called "pattwo" ,wanted to update the old data with new data for this index.without creating the new index.  
My input file is having two records which is already indexed and the records in this file now updated so need to keep these updated data in above index without creating new index.

Please help me out,I tried but still index is showing old data instead of new data.

Please check my logstash configuration file and csv data.  
old CSV data indexed  
S2\_CR\_Browse\_iPhone\_T22\_Click “Cruise&Stay" link from cruise menu,1394,101,92  
S2\_CR\_Browse\_desktop\_T2\_Destinations View All,2785,354,288

New CSV data need to be indexed  
S2\_CR\_Browse\_iPhone\_T22\_Click “Cruise&Stay" link from cruise menu,1395,101,92  
S2\_CR\_Browse\_desktop\_T2\_Destinations View All,2785,354,288

input {  
file {  
type =\> "jmetern"  
path =\> ["D:/pat20.csv"]  
start\_position =\> "beginning"  
}  
}

filter {  
if([message]=~"sampler\_label" or [message]=~"TOTAL")  
{  
drop{}  
}else{  
csv {  
columns =\> ["label","SampleCount"]  
skip\_empty\_columns =\> true  
quote\_char =\> "'"  
}  
}  
}  
output {  
elasticsearch {

```
  document_id => "%{label}"
   template => "D:/apache-jmeter-2.13/bin/jmeter-mapping.json"
   template_name => "pattwo"
   template_overwrite => false
   hosts => "localhost"
   index => "pattwo"
}

```

}

Here label field is having unique value so I am referring that as document id.

hits": {  
"total": 2,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "pattwo",  
"\_type": "jmetern",  
"\_id": "\"S2\_CR\_Browse\_iPhone\_T22\_Click \x93Cruise&Stay\"\" link from cruise menu\"",  
"\_score": 1,  
"\_source": {  
"message": "\"S2\_CR\_Browse\_iPhone\_T22\_Click \x93Cruise&Stay\"\" link from cruise menu\",1394,101,92\r",  
"@version": "1",  
"@timestamp": "2016-07-19T17:19:11.983Z",  
"path": "D:/pat20.csv",  
"host": "BG3WS0057",  
"type": "jmetern",  
"label": "\"S2\_CR\_Browse\_iPhone\_T22\_Click \x93Cruise&Stay\"\" link from cruise menu\"",  
"SampleCount": "1394",  
"column3": "101",  
"column4": "92\r"  
}  
},  
{  
"\_index": "pattwo",  
"\_type": "jmetern",  
"\_id": "S2\_CR\_Browse\_desktop\_T2\_Destinations View All",  
"\_score": 1,  
"\_source": {  
"message": "S2\_CR\_Browse\_desktop\_T2\_Destinations View All,2785,354,288\r",  
"@version": "1",  
"@timestamp": "2016-07-19T17:19:11.986Z",  
"path": "D:/pat20.csv",  
"host": "BG3WS0057",  
"type": "jmetern",  
"label": "S2\_CR\_Browse\_desktop\_T2\_Destinations View All",  
"SampleCount": "2785",  
"column3": "354",  
"column4": "288"  
}  
}  
]  
}

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [July 20, 2016, 10:33am UTC](https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908/2 "2016-07-20T10:33:40Z")

</div>

> [@AnantPatil](#):
>
> template =\> "D:/apache-jmeter-2.13/bin/jmeter-mapping.json"  
> template\_overwrite =\> false

Having both of these means your template won't be applied.[quote="AnantPatil, post:1, topic:55908"]  
Here label field is having unique value so I am referring that as document id.  
[/quote]

That's not really a good ID, but it should work.  
Have you tried updating a document manually and seeing if the `_version` increments?

---

<div class="post-metadata">

### Author: ![AnantPatil](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@AnantPatil](https://discuss.elastic.co/u/AnantPatil)
#### Post date: [July 20, 2016, 12:10pm UTC](https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908/3 "2016-07-20T12:10:13Z")

</div>

Hi warkolm,

Thank you for your reply.

Now I changed the template\_overwrite from false to true in order to apply my customized template.  
template =\> "D:/apache-jmeter-2.13/bin/jmeter-mapping.json"  
template\_overwrite =\> true

Considering the second point,label names are unique so passing document id as label name,remaining columns value will be changed every time so thought to mention the label names are document\_id,Please let me know if you have any better idea so its great help to me.

The indexing getting updating if I changed the file name with different name then those new contents getting updated in existing index.

for Ex: a.csv is having two rows data and indexed  
S2\_CR\_Browse\_iPhone\_T22\_Click “Cruise&Stay" link from cruise menu,1394,101,92  
S2\_CR\_Browse\_desktop\_T2\_Destinations View All,2785,354,288

Now the content of a.csv got changed and updating these content in ealier generated index is not happening,Its happening only when I changed the a.csv to some other name like b.csv then these updated content are getting updated in existing index.any solution without changing the file name need to updated in existing index.

This is first time I am working on ELK.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [July 20, 2016, 10:12pm UTC](https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908/4 "2016-07-20T22:12:23Z")

</div>

Ahh ok, then that is likely a sincedb problem. Have a read of [https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html#\_tracking\_of\_current\_position\_in\_watched\_files](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html#_tracking_of_current_position_in_watched_files)

---

<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, 4:47am UTC](https://discuss.elastic.co/t/replace-the-existing-index-with-new-data/55908/5 "2017-07-06T04:47:06Z")

</div>


