# Logstash hangs on using document\_id while creating index for first time

**URL:** <https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701>\
**Category:** Logstash\
**Created:** [July 5, 2018, 11:05am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701 "2018-07-05T11:05:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aashishgahlawat](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@aashishgahlawat](https://discuss.elastic.co/u/aashishgahlawat)\
**Post date:** [July 5, 2018, 11:05am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/1 "2018-07-05T11:05:01Z")

</div>

```
input {
      jdbc {
    jdbc_driver_library => "sqljdbc42.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://localhost:1433;databaseName=transactions_sample_db"
    jdbc_user => "sa"
    jdbc_password => "awesome"
    statement => "SELECT * from sample"
    # schedule => "* * * * *"
      }
    }
output {
stdout { codec => json_lines }
elasticsearch {
hosts => ["localhost:9200"]
index => "test_index_4"
document_id => "%{[_id]}"
}
}

```

the above code describes my config file,  
and am doing all configurations and everything on my windows laptop (4gb ram) , am new to logstash.  
The Problem is:

1. If i run logstash to create a new index that id not in elasticsearch **without document\_id in conf file** it works fine, but if i create a new index with **document\_id** it hangs forever, here are all files i have in logstash attached
2. The document\_id works fine if index is already present, then it avoids duplicates.
3. Do i have to change my config file when am creating index for first time, and then add document it later? as \_id is not present for first time?

(my elastic search is always running and also i can see indexes on [http://localhost:9200/\_cat/indices?v](http://localhost:9200/_cat/indices?v))

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/2/22cc4991d28c58c5bd36947cd52adf82e255c157.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/7/e7544c86cf3f713d64e0ebdb690acec1d580a041.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/0/40b746ea1ba59a751de707e552411a70353b62c5.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/6/f6fbafb1a034e45936f7f0a7ff594b35e6379404.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2018, 11:07am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/2 "2018-07-05T11:07:52Z")

</div>

Does the event really have an `_id` field? From the log it seems the correct name is `t_id`.

---

<div class="post-metadata">

**Author:** ![aashishgahlawat](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@aashishgahlawat](https://discuss.elastic.co/u/aashishgahlawat)\
**Post date:** [July 5, 2018, 11:16am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/3 "2018-07-05T11:16:00Z")

</div>

for the first time upload it doesnt has.  
i tried using t\_id but that doesn't help me avoid duplicacy then

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/4/f416cb0bd16868f814d268528fb162bc7da968a2.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/a/ead02d725bd7a3ec4a13ce6f2d65ddd6226b94f5.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2018, 11:18am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/4 "2018-07-05T11:18:27Z")

</div>

If the `_id` field does not exist, you will end up updating the same document repeatedly, which will be very inefficient and slow as this will result in a lot of very small refreshes (which are expensive) in recent version.

---

<div class="post-metadata">

**Author:** ![aashishgahlawat](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@aashishgahlawat](https://discuss.elastic.co/u/aashishgahlawat)\
**Post date:** [July 5, 2018, 11:22am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/5 "2018-07-05T11:22:13Z")

</div>

I got it but can you please help me know what to use in place of \_id? t\_id and id are my primary keys in database, I tried using t\_id , it duplicated them, i had 30 lac documents and running it using t\_id added 20k more again

---

<div class="post-metadata">

**Author:** ![aashishgahlawat](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@aashishgahlawat](https://discuss.elastic.co/u/aashishgahlawat)\
**Post date:** [July 5, 2018, 11:37am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/6 "2018-07-05T11:37:06Z")

</div>

thanks i changed them and it worked fine!

---

<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:** [August 2, 2018, 11:37am UTC](https://discuss.elastic.co/t/logstash-hangs-on-using-document-id-while-creating-index-for-first-time/138701/7 "2018-08-02T11:37:10Z")

</div>

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