From 1ce8b3f40773e3eff5e21e9944c9e3a2f0897384 Mon Sep 17 00:00:00 2001 From: Daniel K Date: Thu, 11 Apr 2024 09:41:09 +0200 Subject: [PATCH] trailing paths cleanup as bulk operations - not limited to created to ECS mapping script created one --- scripts/mongo/ecs_trailing_slash_cleanup.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/mongo/ecs_trailing_slash_cleanup.js b/scripts/mongo/ecs_trailing_slash_cleanup.js index 44fde7212..737efe72c 100644 --- a/scripts/mongo/ecs_trailing_slash_cleanup.js +++ b/scripts/mongo/ecs_trailing_slash_cleanup.js @@ -13,16 +13,15 @@ * limitations under the License. */ -// Removes trailing slashes from ECS-mapped paths +// Removes trailing slashes from 's3a://.../' paths (ECS-mapped paths and derived further from there) -function stripTrailingSlashOps(collectionName, fieldToStrip, requiredFieldToExist) { +function stripTrailingSlashOps(collectionName, fieldToStrip) { print(`PrepOps: Stripping trailing / from field ${fieldToStrip} collection in ${collectionName}`); var count = 0; var ops = db[collectionName].find( { "$and": [ - {[requiredFieldToExist]: {$exists: true}}, - {[fieldToStrip]: {$regex: "/$"}} + {[fieldToStrip]: {$regex: "s3a://.*/$"}} ] } ).map(function (doc) { @@ -45,12 +44,12 @@ function stripTrailingSlashOps(collectionName, fieldToStrip, requiredFieldToExis return ops; } -var ops_d1 = stripTrailingSlashOps("dataset_v1", "hdfsPath", "bakHdfsPath"); +var ops_d1 = stripTrailingSlashOps("dataset_v1", "hdfsPath"); db.getCollection('dataset_v1').bulkWrite(ops_d1); -var ops_d2 = stripTrailingSlashOps("dataset_v1", "hdfsPublishPath", "bakHdfsPublishPath"); +var ops_d2 = stripTrailingSlashOps("dataset_v1", "hdfsPublishPath"); db.getCollection('dataset_v1').bulkWrite(ops_d2); -var ops_mt1 = stripTrailingSlashOps("mapping_table_v1", "hdfsPath", "bakHdfsPath"); +var ops_mt1 = stripTrailingSlashOps("mapping_table_v1", "hdfsPath"); db.getCollection('mapping_table_v1').bulkWrite(ops_mt1);