# Importing to an existing index in Elastic doesn't behave as expected

**URL:** https://discuss.elastic.co/t/importing-to-an-existing-index-in-elastic-doesnt-behave-as-expected/332225
**Category:** Elasticsearch
**Created:** [May 2, 2023, 9:15am UTC](https://discuss.elastic.co/t/importing-to-an-existing-index-in-elastic-doesnt-behave-as-expected/332225 "2023-05-02T09:15:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![eeijlar](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@eeijlar](https://discuss.elastic.co/u/eeijlar)
#### Post date: [May 2, 2023, 9:15am UTC](https://discuss.elastic.co/t/importing-to-an-existing-index-in-elastic-doesnt-behave-as-expected/332225/1 "2023-05-02T09:15:07Z")

</div>

I am exporting from one ELK stack using logstash. I am writing the output to a json gz file.

Then I am importing to another ELK stack also using logstash. There is no connection between the two environments.

This export/import can occur multiple times throughout the day.

I have noticed that when the the target index exists in 2nd environment, it seems to just append documents onto the end of the index. So, I might get 200k documents imported instead of maybe 5 million documents.

This is my import pipeline for the metricbeat index:

```auto
input {
  file {
    path => "/usr/share/logstash/export/export_metricbeat-7.17.7-2023.04.28-000007.json"
    start_position => "beginning"
    codec => "json"
    mode => "read"
    exit_after_read => true
  }
}

output {
  elasticsearch {
     hosts => "http://localhost:9200"
     index => "metricbeat-7.17.7-2023.04.28-000007"
     ssl => "false"
  }
}

```

If I had already done an import on the 28th of April, then this index will already exist in the target environment.

Is there a way in logstash to always import no matter what exists in Elastic? I thought it might be duplicate document ids, but I don't see how that's possible. The document ids should be unique.

---

<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: [May 30, 2023, 9:15am UTC](https://discuss.elastic.co/t/importing-to-an-existing-index-in-elastic-doesnt-behave-as-expected/332225/2 "2023-05-30T09:15:44Z")

</div>

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