I've being messing about with both Elasticsearch.net (http://nest.azurewebsites.net/) and PlainElastic.Net(https://github.com/Yegoroff/PlainElastic.Net) and have been able to insert single documents into elasticsearch. I am now trying to figure out how to perform a bulk insert. I know each of these two .net libraries have documentation around this, but the data I wish to insert is stored in a dictionary where the key is the ID of the document and value is the document and I cannot figure out how to do it.
Here is some code I have (using Elasticsearch.net) :
var conn = new Uri("http://localhost:9200");
var config = new ConnectionConfiguration(conn);
var client = new ElasticsearchClient(config);
var myJson = @"{""Col1"" : ""Hello World"", ""col2"" : ""asdfasdf"" }";
var myjson2 = @"{""Col2"" : ""Hello World Again"", ""col2"" : ""zxcvzxcv"" }";
Dictionary<string, string> jsonCollection = new Dictionary<string, string>();
jsonCollection.Add("1", myJson);
jsonCollection.Add("2", myjson2);
I use PlainElastic.Net and this is how RAW data should look like
keep in mind that new line is at the end of every row (yes even after last line)
so vb.net should look like this:
c# version I didn't test but you'll get the idea
You can create JSON manually or with Newtonsoft.Json