fix: wrong way alias names are generated

Closes #79
This commit is contained in:
Jovan Krunić
2021-03-29 18:06:50 +02:00
committed by Rainer Killinger
parent ff9fb49deb
commit 9488451080
2 changed files with 15 additions and 4 deletions

View File

@@ -141,10 +141,13 @@ export class Elasticsearch implements Database {
* @param uid The UID of the current bulk (for debugging purposes)
*/
static removeAliasChars(alias: string, uid: string | undefined): string {
// spaces are included in some types, so throwing an error in this case would clutter up the log unnecessarily
let formattedAlias = alias;
while (formattedAlias.includes(' ')) {
formattedAlias = formattedAlias.replace(' ', '');
// spaces are included in some types, replace them with underscores
if (formattedAlias.includes(' ')) {
formattedAlias = formattedAlias.trim();
formattedAlias = formattedAlias.split(' ')
.join('_');
}
// List of invalid characters: https://www.elastic.co/guide/en/elasticsearch/reference/6.6/indices-create-index.html
['\\', '/', '*', '?', '"', '<', '>', '|', ',', '#'].forEach((value) => {