Permalink
Browse files

Return json to callbacks since that is what ES sends.

Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
  • Loading branch information...
1 parent e5f24b3 commit e287bf4f25ae87cfeb28d42972c0381b7e055a38 @ncb000gt committed Mar 2, 2011
Showing with 1 addition and 4 deletions.
  1. +1 −1 lib/elasticsearch.js
  2. +0 −3 tests/test-client.js
View
@@ -111,7 +111,7 @@ ElasticSearch.prototype._request = function(opts, data, cb) {
});
if (cb) {
- cb(null, buf);
+ cb(null, JSON.parse(buf.toString()));
}
});
});
View
@@ -6,7 +6,6 @@ module.exports = {
var n = 0;
var client = lib.createClient({index:'_all'});
client.status({}, function(err, status) {
- status = JSON.parse(status.toString());
assert.ok(status.ok);
n++;
});
@@ -19,11 +18,9 @@ module.exports = {
var doc = {field1: 'test field', field2: 'second test field'};
var client = lib.createClient({index:'test'});
client.add({type:'info', id:'1'}, doc, function(err, result) {
- result = JSON.parse(result.toString());
assert.ok(result.ok);
n++;
client.query({query: {field: {field1: 'test'}}}, function(err, result) {
- result = JSON.parse(result.toString());
assert.equal(result.hits.total, 1);
assert.deepEqual(result.hits.hits[0]._source, doc);
n++;

0 comments on commit e287bf4

Please sign in to comment.