From aec1e938a806e0bb1eb4ba3a3c5e71a75dcb356c Mon Sep 17 00:00:00 2001 From: Evan Tahler Date: Sat, 29 Oct 2016 15:52:00 -0700 Subject: [PATCH] v0.0.14 --- .travis.yml | 5 +-- lib/connections/elasticsearch.js | 12 +++--- package.json | 2 +- test/connections/elasticsearch.js | 62 +++++++++++++++---------------- 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/.travis.yml b/.travis.yml index 46e8ddf..5d76a08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,5 @@ services: language: node_js node_js: - - "0.10" - - "0.12" - - "iojs" - "4.0" - - "5.0" + - "6.0" diff --git a/lib/connections/elasticsearch.js b/lib/connections/elasticsearch.js index e08cf69..680c79e 100644 --- a/lib/connections/elasticsearch.js +++ b/lib/connections/elasticsearch.js @@ -42,7 +42,7 @@ connection.prototype.insertData = function(index, data, callback){ body: { doc: d } }, function(error){ if(error){ - if(error.message.match(/DocumentMissingException/)){ + if(error.message.match(/DocumentMissingException/) || error.message.match(/document_missing_exception/)){ writeMethod = 'create'; self.connection[writeMethod]({ @@ -69,7 +69,7 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall var self = this; var scrollTime = '5m'; if(!rowsFound){ rowsFound = 0; } - + var payload = { index: index, scroll: scrollTime, @@ -84,7 +84,7 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall self.book.logger.log(' ' + self.name + '/' + self.type + ' >> ' + JSON.stringify(payload), 'debug'); self.connection.search(payload, function getMoreUntilDone(error, response){ - if(error){ + if(error){ return doneCallback(error, rowsFound); }else if(response.hits.hits.length === 0){ doneCallback(null, rowsFound); @@ -92,7 +92,7 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall rowsFound += response.hits.hits.length; var simpleData = []; - response.hits.hits.forEach(function(hit){ + response.hits.hits.forEach(function(hit){ var row = {}; if(hit.fields){ @@ -113,7 +113,7 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall } } - simpleData.push( row ); + simpleData.push( row ); }); dataCallback(null, simpleData, function(){ @@ -130,4 +130,4 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall }); }; -exports.connection = connection; \ No newline at end of file +exports.connection = connection; diff --git a/package.json b/package.json index 2ded719..fa5b0e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "empujar", - "version": "0.0.13", + "version": "0.0.14", "description": "When you need to push data around, you push it. Push it real good. An ETL and Operations tool.", "main": "index.js", "engines": { diff --git a/test/connections/elasticsearch.js b/test/connections/elasticsearch.js index 34c58c8..9a98ba7 100644 --- a/test/connections/elasticsearch.js +++ b/test/connections/elasticsearch.js @@ -49,9 +49,9 @@ describe('connection: elasticsearch', function(){ beforeEach(function(done){ helper.indices.delete({index: index}, function(error){ setTimeout(function(){ - if(!error || error.message.match(/IndexMissingException/)){ + if(!error || error.message.match(/IndexMissingException/) || error.message.match(/index_not_found/) ){ done(); - }else{ + }else{ done(error); } }, sleep); @@ -63,12 +63,12 @@ describe('connection: elasticsearch', function(){ // null, int, float, boolean, small-text, large-text, date, primary key var data = [ { - id: 1, - counter: 4, - happy: true, - money: 100.012, - when: new Date(1448486552507), - small_words: 'a small amount of words', + id: 1, + counter: 4, + happy: true, + money: 100.012, + when: new Date(1448486552507), + small_words: 'a small amount of words', } ]; @@ -99,12 +99,12 @@ describe('connection: elasticsearch', function(){ // null, int, float, boolean, small-text, large-text, date, primary key var data = [ { - id: 1, - counter: 4, - happy: true, - money: 100.012, - when: new Date(1448486552507), - small_words: 'a small amount of words', + id: 1, + counter: 4, + happy: true, + money: 100.012, + when: new Date(1448486552507), + small_words: 'a small amount of words', } ]; @@ -114,8 +114,8 @@ describe('connection: elasticsearch', function(){ data = [ { - id: 1, - happy: false, + id: 1, + happy: false, } ]; @@ -151,25 +151,25 @@ describe('connection: elasticsearch', function(){ helper.indices.delete({index: index}, function(error){ setTimeout(function(){ if(!error || error.message.match(/IndexMissingException/)){ - + var data = [ { - id: 1, - email: 'evan@taskrabbit.com', - first_name: 'evan', - when: new Date(1448486552507), + id: 1, + email: 'evan@taskrabbit.com', + first_name: 'evan', + when: new Date(1448486552507), }, { - id: 2, - email: 'aaron@taskrabbit.com', - first_name: 'aaron', - when: new Date(), + id: 2, + email: 'aaron@taskrabbit.com', + first_name: 'aaron', + when: new Date(), }, { - id: 3, - email: 'pablo@taskrabbit.com', - first_name: 'pablo', - when: new Date(), + id: 3, + email: 'pablo@taskrabbit.com', + first_name: 'pablo', + when: new Date(), } ]; @@ -179,7 +179,7 @@ describe('connection: elasticsearch', function(){ }, sleep); }); - }else{ + }else{ done(error); } }, sleep); @@ -284,4 +284,4 @@ describe('connection: elasticsearch', function(){ }); -}); \ No newline at end of file +});