Skip to content

Commit

Permalink
feat(version): remove _type
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Mar 13, 2024
1 parent 58fac7e commit 382850e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 46 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ const stream = streamify([1, 2, 3])
.pipe(dbclient()); // put documents into elasticsearch

stream.on('finish', () => {
// let's assume that documents with the same type but another timestamp (for example old copies)
// have to be deleted
const client = new elasticsearch.Client(config.esclient);
elasticDeleteQuery(client);

const options = {
index: config.schema.indexName,
type: 'venue',
body: {
query: {
"bool": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"dependencies": {
"@hapi/joi": "^16.0.0",
"elasticsearch": "^16.0.0",
"pelias-config": "^5.2.0",
"pelias-config": "^6.0.0",
"pelias-logger": "^1.2.1",
"through2": "^3.0.0"
},
Expand Down
11 changes: 1 addition & 10 deletions src/BatchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,18 @@ BatchManager.prototype._dispatch = function( batch, next ){
this._stats.inc( 'indexed', batch._slots.length );
this._stats.inc( 'batch_ok', 1 );

var types = {};
var failures = 0;

batch._slots.forEach( function( task ){
if( task.status < 299 ){
const type = task.data.layer || task.cmd.index._type;
if( !types.hasOwnProperty( type ) ){
types[ type ] = 0;
}
types[ type ]++;
this._stats.inc( task.data.layer || 'default', 1 );
} else {
failures++;
}
});

this._stats.inc( 'batch_retries', batch.retries );
this._stats.inc( 'failed_records', failures );

for( var type in types ){
this._stats.inc( type, types[type] );
}
}

// console.log( 'batch complete', err, batch._slots.length );
Expand Down
1 change: 0 additions & 1 deletion src/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ function Task( record ){
this.cmd = {
index: {
_index: record._index,
_type: record._type,
_id: record._id
}
};
Expand Down
3 changes: 1 addition & 2 deletions src/configValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const schema = Joi.object().keys({
requestTimeout: Joi.number().integer().min(0)
}).unknown(true),
schema: Joi.object().keys({
indexName: Joi.string().required(),
typeName: Joi.string().required()
indexName: Joi.string().required()
})
}).unknown(true);

Expand Down
42 changes: 14 additions & 28 deletions test/configValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ module.exports.tests.validate = function(test, common) {
var config = {
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -30,8 +29,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -51,8 +49,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -74,8 +71,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -94,8 +90,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -115,8 +110,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -138,8 +132,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -160,8 +153,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: value,
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -186,8 +178,7 @@ module.exports.tests.validate = function(test, common) {
requestTimeout: value
},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -210,8 +201,7 @@ module.exports.tests.validate = function(test, common) {
requestTimeout: 17.3
},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand All @@ -233,8 +223,7 @@ module.exports.tests.validate = function(test, common) {
requestTimeout: -1
},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand Down Expand Up @@ -315,8 +304,7 @@ module.exports.tests.validate = function(test, common) {
},
esclient: {},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand Down Expand Up @@ -344,8 +332,7 @@ module.exports.tests.validate = function(test, common) {
requestTimeout: 17
},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand Down Expand Up @@ -374,8 +361,7 @@ module.exports.tests.validate = function(test, common) {
requestTimeout: 17
},
schema: {
indexName: 'example_index',
typeName: 'example_type'
indexName: 'example_index'
}
};

Expand Down
1 change: 0 additions & 1 deletion test/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports.tests.functional_example = function(test, common) {
stream.pipe(assertStream);
stream.write({
_index: 'foo',
_type: 'foo',
_id: 'foo',
data: {}
});
Expand Down

0 comments on commit 382850e

Please sign in to comment.