# "illegal\_argument\_exception", "reason"=\>"if \_id is specified it must not be empty"

**URL:** <https://discuss.elastic.co/t/illegal-argument-exception-reason-if-id-is-specified-it-must-not-be-empty/234826>\
**Category:** Logstash\
**Created:** [May 28, 2020, 9:48pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reason-if-id-is-specified-it-must-not-be-empty/234826 "2020-05-28T21:48:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tenet\_testuser1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tenet_testuser1/32/67526_2.png) [@tenet\_testuser1](https://discuss.elastic.co/u/tenet_testuser1)\
**Post date:** [May 28, 2020, 9:48pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reason-if-id-is-specified-it-must-not-be-empty/234826/1 "2020-05-28T21:48:59Z")

</div>

Hello,

I have setup a logstash pipeline. It works fine bringing the updates and refreshing the index. However, it throws an error while bringing updates. I am trying to understand the reasons behind.

output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200/)"]  
index =\> "contactsx"  
document\_type =\> "contactx"  
document\_id =\> "%{symbol}"  
}

[2020-05-25T11:59:13,962][WARN][logstash.outputs.elasticsearch][company\_listing] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>"", :\_index=\>"contactsx", :routing=\>nil, :\_type=\>"contactx"}, #LogStash::Event:0x56578469], :response=\>{"index"=\>{"\_index"=\>"contactsx", "\_type"=\>"contactx", "\_id"=\>"", "status"=\>400, "error"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"if \_id is specified it must not be empty"}}}}

by changing it to this "with a constant "\_Z", document\_id =\> "%{symbol}\_z", there are no errors.

output {  
elasticsearch {  
hosts =\> ["[http://localhost:9200](http://localhost:9200/)"]  
index =\> "contactsx"  
document\_type =\> "contactx"  
document\_id =\> "%{symbol}\_z"  
}

Can you please explain what's going on here?  
The column symbol is primary key in the db.  
Why does logstash say id is NULL in the first setting?

---

<div class="post-metadata">

**Author:** ![tenet\_testuser1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tenet_testuser1/32/67526_2.png) [@tenet\_testuser1](https://discuss.elastic.co/u/tenet_testuser1)\
**Post date:** [May 28, 2020, 9:49pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reason-if-id-is-specified-it-must-not-be-empty/234826/2 "2020-05-28T21:49:59Z")

</div>

json sample data

With \_Z appended to the pipeline directive

symbol:  
HCHC  
@version:  
1  
@timestamp:  
2020-05-27  
companyname:  
HC2 Holdings, Inc.  
\_id:  
HCHC\_z  
\_type:  
contactx  
\_index:  
contactsx  
\_score:  
0  
################################################################

Without \_Z appended  
#####################

symbol:  
HCHC  
companyname:  
HC2 Holdings, Inc.  
@timestamp:  
2020-05-27  
@version:  
1  
\_id:  
HCHC  
\_type:  
contactx  
\_index:  
contactsx  
\_score:  
0

---

<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:** [June 25, 2020, 9:50pm UTC](https://discuss.elastic.co/t/illegal-argument-exception-reason-if-id-is-specified-it-must-not-be-empty/234826/3 "2020-06-25T21:50:05Z")

</div>

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