# ElasticSearch.Net Bulk - JsonParseException\[Unexpected character (',' (code 44)):

**URL:** <https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540>\
**Category:** Elasticsearch\
**Created:** [August 17, 2015, 9:18pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540 "2015-08-17T21:18:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garrett\_Johnson](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@Garrett\_Johnson](https://discuss.elastic.co/u/Garrett_Johnson)\
**Post date:** [August 17, 2015, 9:18pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540/1 "2015-08-17T21:18:29Z")

</div>

I'm trying to do bulk inserts using [ElasticSearch.net](http://ElasticSearch.net) but am getting this issue:

{"error":"JsonParseException[Unexpected character (',' (code 44)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty.ChannelBufferStreamInput@2c347b7; line: 1, column: 2]]","status":500}

Code:

public void BulkIndex(object mydata, string indexType)  
{  
ElasticsearchResponse searchResponse;  
string output = JsonConvert.SerializeObject(myData);  
if (output != "[]")  
{  
ConnectionConfiguration config = new ConnectionConfiguration(new Uri(this.uri));  
ConnectionConfiguration exposed = config.ExposeRawResponse(true);  
ElasticsearchClient client = new ElasticsearchClient(config, null, null, null);  
output = output.Replace("}", "}\r\n");  
searchResponse = client.Bulk("jdbc", indexType, output);

```
                if (searchResponse != null)
                  Console.WriteLine(searchResponse.Response);
                
            }

```

}

object is the results of a linq query.

The JSON is nice and i'm adding the carriage return line feeds:

I believe it is crashing on this part:

[{"\_id":"DW1Nh31izEyyKlBWu/","MyFieldName":null,"

The null?

I have lots of nulls and not sure what to do since I'm not mapping it.

Is that the problem? It is trying to Map the field and can't because null isn't valid.

If I ignore Null columns will it keep adding to the mapping on it's own?

Any one else using Bulk Inserts with Linq to a dbml as the source and successful?

I will be passing many types to the same code and the types are variant and are not predefined.

Garrett

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [August 17, 2015, 10:01pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540/2 "2015-08-17T22:01:26Z")

</div>

If you do this does it work:

1. Create a file called test.txt with the following:

```auto
{ "index" : { "_index" : "testing1", "_type" : "type1", "_id" : "1" } }
{ "field1" : "foo bar" }
{ "index" : { "_index" : "testing1", "_type" : "type1", "_id" : "2" } }
{ "field1" : null }

```

1. Run:

curl -s -XPOST localhost:9200/\_bulk --data-binary @test.txt

1. If you do GET /testing1/\_search it should return 2 documents. One with field1 = "foo bar" and one as null.

Do you have strict set to for your mapping?

[https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html)

---

<div class="post-metadata">

**Author:** ![Garrett\_Johnson](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@Garrett\_Johnson](https://discuss.elastic.co/u/Garrett_Johnson)\
**Post date:** [August 18, 2015, 12:20pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540/3 "2015-08-18T12:20:04Z")

</div>

My ES farm is working with JDBC rivers now.

What I'm trying to do is create my own Windows Feeder Service that translates Linq output to JSON and creates an index.

I don't have a mapping. I was hoping to get away with creating the index and the mapping would be discovered. But because a lot of my data is null ES doesn't like it.

Or should I just not send null data?

---

<div class="post-metadata">

**Author:** ![Garrett\_Johnson](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@Garrett\_Johnson](https://discuss.elastic.co/u/Garrett_Johnson)\
**Post date:** [August 20, 2015, 7:47pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540/4 "2015-08-20T19:47:25Z")

</div>

Yes the simple example works with nulls.

---

<div class="post-metadata">

**Author:** ![Garrett\_Johnson](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@Garrett\_Johnson](https://discuss.elastic.co/u/Garrett_Johnson)\
**Post date:** [August 20, 2015, 8:43pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540/5 "2015-08-20T20:43:48Z")

</div>

Ok I think I know what i'm doing wrong.

I'm trying to do this:

{ "index" : { "\_index" : "jdbc", "\_type" : "testing1"} }\r\n"+  
{ "\_id" : "1" , "field1":null}\r\n  
{ "index" : { "\_index" : "jdbc", "\_type" : "testing1",} }\r\n  
{ "\_id" : "2" , "field1":"foobar" }\r\n\r\n

Because my original json dataset has the ID's in it. I don't have a data set that has just the id's.

I have no idea how to easily stuff the ID's from the object output into a separate string.

Is there a way to tell it that the ID is in the doc?

---

<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 5, 2017, 11:54pm UTC](https://discuss.elastic.co/t/elasticsearch-net-bulk-jsonparseexception-unexpected-character-code-44/27540/6 "2017-07-05T23:54:48Z")

</div>


