# Unable to import to ES / Error occurred sending a bulk request to Elasticsearch

**URL:** https://discuss.elastic.co/t/unable-to-import-to-es-error-occurred-sending-a-bulk-request-to-elasticsearch/197565
**Category:** Logstash
**Created:** [August 30, 2019, 6:12pm UTC](https://discuss.elastic.co/t/unable-to-import-to-es-error-occurred-sending-a-bulk-request-to-elasticsearch/197565 "2019-08-30T18:12:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Alexandre.Bernier](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@Alexandre.Bernier](https://discuss.elastic.co/u/Alexandre.Bernier)
#### Post date: [August 30, 2019, 6:12pm UTC](https://discuss.elastic.co/t/unable-to-import-to-es-error-occurred-sending-a-bulk-request-to-elasticsearch/197565/1 "2019-08-30T18:12:14Z")

</div>

Hello community,

I'm desperately trying to import data into Elasticsearch with Logstash from MS SQL Server 2012R2 but it fails all the time with the following error:

```
[2019-08-30T10:57:11,347][ERROR][logstash.outputs.elasticsearch] An unknown error occurred sending a bulk request to Elasticsearch. We will retry indefinitely {:error_message=>"\"\\x96\" from ASCII-8BIT to UTF-8", :error_class=>"LogStash::Json::GeneratorError", :backtrace=>["E:/Logstash/logstash-7.3.0/logstash-core/lib/logstash/json.rb:27:in `jruby_dump'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/http_client.rb:119:in `block in bulk'", "org/jruby/RubyArray.java:2577:in `map'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/http_client.rb:119:in `block in bulk'", "org/jruby/RubyArray.java:1792:in `each'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/http_client.rb:117:in `bulk'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/common.rb:296:in `safe_bulk'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/common.rb:201:in `submit'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/common.rb:169:in `retrying_submit'", "E:/Logstash/logstash-7.3.0/vendor/bundle/jruby/2.5.0/gems/logstash-output-elasticsearch-10.1.0-java/lib/logstash/outputs/elasticsearch/common.rb:38:in `multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:118:in `multi_receive'", "org/logstash/config/ir/compiler/AbstractOutputDelegatorExt.java:101:in `multi_receive'", "E:/Logstash/logstash-7.3.0/logstash-core/lib/logstash/java_pipeline.rb:239:in `block in start_workers'"]}

```

Here's the table that I'm querying from:  
 ![TableExample](https://us1.discourse-cdn.com/elastic/original/3X/1/0/102a888bcfff9269d20b16ddff22b55c3ef4b32e.png)

Here's a row sample from the table:

 ![RowExample](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1a6280fa00e0111356593dda4622ec69a7ca4b23.png)

I know that the issue come from the column "SysRevID". As soon as I remove this field from the query in Logstash, the script runs correctly.

The problem is that I need this field since it is the one who manage the version of the row in my database. If the number is different, it's because there was a change on the row and I need to update the document in ES.

Here's my config that I'm using with Logstash (I removed the settings that were not useful for this issue):

```
input {
	jdbc {
		statement => "SELECT * FROM [DATABASE].[dbo].[TEST]"
	}
}
output {
	elasticsearch {
		index => "logstash-ud08-%{+YYYY.MM.dd}"
	}
}

```

I tried different thing to convert / change the charset of the column but nothing work.

I'm quite new to the stack so I don't understand all the settings.

Here's the specs that I'm using:

- ElasticSearch 7.3
- Kibana 7.3
- Logstash 7.3
- SQL Server Collation Name : French\_CI\_AS

Finally, the question is.. what can I do to keep this field in my SELECT query?

Thanks!  
Alexandre

---

<div class="post-metadata">

### Author: ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)
#### Post date: [September 2, 2019, 9:14am UTC](https://discuss.elastic.co/t/unable-to-import-to-es-error-occurred-sending-a-bulk-request-to-elasticsearch/197565/2 "2019-09-02T09:14:18Z")

</div>

From...  
[https://docs.microsoft.com/en-us/sql/connect/jdbc/understanding-data-type-differences?view=sql-server-2017#binary-string-types](https://docs.microsoft.com/en-us/sql/connect/jdbc/understanding-data-type-differences?view=sql-server-2017#binary-string-types)  
I see that a MS Sqlserver timestamp data type maps to a JDBC Binary data type.

Then in this...

> <https://stackoverflow.com/questions/52739338/logstash-jdbc-adapter-varbinary-to-utf-8-mysql-to-elastic-import>

  
I see the same error message as you have and a solution.

---

<div class="post-metadata">

### Author: ![Alexandre.Bernier](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@Alexandre.Bernier](https://discuss.elastic.co/u/Alexandre.Bernier)
#### Post date: [September 3, 2019, 2:44pm UTC](https://discuss.elastic.co/t/unable-to-import-to-es-error-occurred-sending-a-bulk-request-to-elasticsearch/197565/3 "2019-09-03T14:44:03Z")

</div>

Hi @guyboertje,

It works!

But I realize that I already try this solution before posting my question except that I writed the name of my column with capital letters "SysRevID" and not like this "sysrevid" the first time I tried...

Here's the final config:

```
input {
	jdbc {
		statement => "SELECT * FROM [DATABASE].[dbo].[TEST]"
	    columns_charset => { "sysrevid" => "UTF-8" }
	}
}
output {
	elasticsearch {
		index => "logstash-ud08-%{+YYYY.MM.dd}"
	}
}

```

Thanks for the links and the answer!  
Have a nice week!  
Alexandre

---

<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: [October 1, 2019, 2:44pm UTC](https://discuss.elastic.co/t/unable-to-import-to-es-error-occurred-sending-a-bulk-request-to-elasticsearch/197565/4 "2019-10-01T14:44:03Z")

</div>

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