Skip to content

Commit

Permalink
fix(doc): Do not allow duplicate names to be created
Browse files Browse the repository at this point in the history
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
pelias/model#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.
  • Loading branch information
orangejulius committed Aug 13, 2020
1 parent 12cd520 commit a6c80a2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/peliasDocGenerators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a6c80a2

Please sign in to comment.