I'm trying to do bulk inserts using 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