From a6c80a23557be1d59782f30f40f79fd7f893cf2e Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Tue, 9 Jun 2020 15:53:26 -0700 Subject: [PATCH] fix(doc): Do not allow duplicate names to be created While diagnosing an issue related to scoring, I discovered that WOF records are sometimes created with duplicate name values. While the pelias/model code can detect some of them (and more will be fixed with https://github.com/pelias/model/pull/132), we should fix this issue at the source. Here's an example of what a document might look like today, before this PR: ``` { name: { default: [ 'Kansas City' ] }, phrase: { default: [ 'Kansas City', 'Kansas City' ] }, ... } ``` This can be fixed by checking each potential alternate name against the "primary" name value. --- src/peliasDocGenerators.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/peliasDocGenerators.js b/src/peliasDocGenerators.js index 945bdd69..3cc9ac62 100644 --- a/src/peliasDocGenerators.js +++ b/src/peliasDocGenerators.js @@ -88,7 +88,9 @@ function setupDocument(record, hierarchy) { else { if (record.name_aliases.length) { record.name_aliases.forEach(alias => { - wofDoc.setNameAlias('default', alias); + if (alias !== record.name) { + wofDoc.setNameAlias('default', alias); + } }); } if (record.name_langs) {