Skip to content

Commit

Permalink
v0.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Oct 29, 2016
1 parent c4e6452 commit aec1e93
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ services:
language: node_js

node_js:
- "0.10"
- "0.12"
- "iojs"
- "4.0"
- "5.0"
- "6.0"
12 changes: 6 additions & 6 deletions lib/connections/elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]({
Expand All @@ -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,
Expand All @@ -84,15 +84,15 @@ 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);
}else{
rowsFound += response.hits.hits.length;

var simpleData = [];
response.hits.hits.forEach(function(hit){
response.hits.hits.forEach(function(hit){
var row = {};

if(hit.fields){
Expand All @@ -113,7 +113,7 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall
}
}

simpleData.push( row );
simpleData.push( row );
});

dataCallback(null, simpleData, function(){
Expand All @@ -130,4 +130,4 @@ connection.prototype.getAll = function(index, query, fields, chunkSize, dataCall
});
};

exports.connection = connection;
exports.connection = connection;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
62 changes: 31 additions & 31 deletions test/connections/elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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',
}
];

Expand Down Expand Up @@ -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',
}
];

Expand All @@ -114,8 +114,8 @@ describe('connection: elasticsearch', function(){

data = [
{
id: 1,
happy: false,
id: 1,
happy: false,
}
];

Expand Down Expand Up @@ -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(),
}
];

Expand All @@ -179,7 +179,7 @@ describe('connection: elasticsearch', function(){
}, sleep);
});

}else{
}else{
done(error);
}
}, sleep);
Expand Down Expand Up @@ -284,4 +284,4 @@ describe('connection: elasticsearch', function(){

});

});
});

0 comments on commit aec1e93

Please sign in to comment.