I am able to index easily with this curl command:
curl -XPUT 'http://localhost:9200/prototype_2012.12.27/chow-clfg/Cg-IKkxdTstKAAAAlw-?parent=chow-demo' -d '{"chow-clfg":{"@type":"chow-clfg","clfg":"Cg6h4VCcMexXAAAAsQc","@timestamp":"2012-12-27T08:24:00.000Z","count":1}}'
{"ok":true,"_index":"prototype_2012.12.27","_type":"chow-clfg","_id":"Cg-IKkxdTstKAAAAlw-","_version":1}
This returns me a result almost instantaneously.
However when I try it with the nodejs' http.request method:
var http = require('http');
var index = "prototype_2012.12.27";
var server = "chow-clfg";
var options = {
host: 'localhost',
port: '9200',
path: index+'/'+server+'/Cg-IKkxdTstKAAAAlw-?parent=chow-demo',
method: 'PUT'
};
var req = http.request(options, function(res){
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log(chunk);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.write('{"chow-clfg":{"@type":"chow-clfg","clfg":"Cg6h4VCcMexXAAAAsQc","@timestamp":"2012-12-27T08:24:00.000Z","count":1}}');
req.end;
This just suspends the process mid-way and it does not give me a feedback on whether it is successful or not. Also, when I search for the document in my index, I couldn't find it.
Therefore, is there a coding error that I have made? Or is there any way to rectify the problem?