Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove _type #128

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof we still had type: 'layer' in our docs all this time? 😬

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
13 changes: 2 additions & 11 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 ){
batch._slots.forEach(( 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
Loading