From 1518c956d64da9b3ccbfad9bdc739bd3c17798bb Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Thu, 12 Nov 2020 15:54:52 -0600 Subject: [PATCH 1/9] feat: add array fields --- src/server/es/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index d3a0ab5e..df7a2279 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -322,6 +322,12 @@ class ES { * Get all es indices and their alias */ getAllESIndices() { + // this.fieldTypes = await this._getMappingsForAllIndices(); + // this.arrayFields = await this._getArrayFieldsFromConfigIndex(); + + console.log('inside getAllESIndices with this.arrayFields ', this.arrayFields); + console.log('inside getAllESIndices with this.config.configIndex ', this.config.configIndex); + const indicesArray = this.config.indices.map((e) => e.index); if (this.config.configIndex) { indicesArray.push(this.config.configIndex); @@ -330,11 +336,13 @@ class ES { index: indicesArray, }).then((resp) => { try { + let indicesMetadata = resp.body; + indicesMetadata[this.config.configIndex]["arrayFields"] = this.arrayFields; return { statusCode: resp.statusCode, warnings: resp.warnings, indices: { - ...resp.body, + ...indicesMetadata, }, }; } catch (err) { From 86112f92dd9354dfad365579111e64a0643417f3 Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Thu, 12 Nov 2020 16:54:56 -0600 Subject: [PATCH 2/9] feat: add array fields --- src/server/es/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index df7a2279..1f3980a8 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -337,7 +337,10 @@ class ES { }).then((resp) => { try { let indicesMetadata = resp.body; - indicesMetadata[this.config.configIndex]["arrayFields"] = this.arrayFields; + for (var key in this.arrayFields) { + indicesMetadata[key]["arrayFields"] = this.arrayFields[key]; + } + return { statusCode: resp.statusCode, warnings: resp.warnings, @@ -346,6 +349,7 @@ class ES { }, }; } catch (err) { + console.log('error: ', err); throw new Error(err); } }, (err) => { From cc093719cd14c3d5ab1045afaf58addddfbda44b Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Fri, 13 Nov 2020 16:08:59 -0600 Subject: [PATCH 3/9] feat: add array fields --- src/server/es/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/es/index.js b/src/server/es/index.js index 1f3980a8..124e930e 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -338,6 +338,9 @@ class ES { try { let indicesMetadata = resp.body; for (var key in this.arrayFields) { + if(!indicesMetadata[key]) { + indicesMetadata[key] = {}; + } indicesMetadata[key]["arrayFields"] = this.arrayFields[key]; } From bd9926b1cbafc14356316846760a0af5c454093d Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Sat, 14 Nov 2020 00:22:01 -0600 Subject: [PATCH 4/9] feat: add fieldTypes to status --- src/server/es/index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index 124e930e..8b8fe19f 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -322,16 +322,11 @@ class ES { * Get all es indices and their alias */ getAllESIndices() { - // this.fieldTypes = await this._getMappingsForAllIndices(); - // this.arrayFields = await this._getArrayFieldsFromConfigIndex(); - - console.log('inside getAllESIndices with this.arrayFields ', this.arrayFields); - console.log('inside getAllESIndices with this.config.configIndex ', this.config.configIndex); - const indicesArray = this.config.indices.map((e) => e.index); if (this.config.configIndex) { indicesArray.push(this.config.configIndex); } + indicesArray['fieldTypes'] = this.fieldTypes; return this.client.indices.getAlias({ index: indicesArray, }).then((resp) => { From 232652a44a72367fcc36053cfa61ca50bd22b99d Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Sat, 14 Nov 2020 13:44:53 -0600 Subject: [PATCH 5/9] feat: add fieldTypes to status --- src/server/es/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index 8b8fe19f..65ae4534 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -326,7 +326,6 @@ class ES { if (this.config.configIndex) { indicesArray.push(this.config.configIndex); } - indicesArray['fieldTypes'] = this.fieldTypes; return this.client.indices.getAlias({ index: indicesArray, }).then((resp) => { @@ -338,6 +337,7 @@ class ES { } indicesMetadata[key]["arrayFields"] = this.arrayFields[key]; } + indicesMetadata['fieldTypes'] = this.fieldTypes; return { statusCode: resp.statusCode, From 0e2218266566a49a007513fd1eb580f9d988d962 Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Sun, 15 Nov 2020 13:33:39 -0600 Subject: [PATCH 6/9] chore: run eslint --- src/server/endpoints.js | 1 - src/server/es/index.js | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/server/endpoints.js b/src/server/endpoints.js index ff1c273d..994f01fa 100644 --- a/src/server/endpoints.js +++ b/src/server/endpoints.js @@ -1,4 +1,3 @@ - import esInstance from './es/index'; import { gitVersion, gitCommit } from './version'; diff --git a/src/server/es/index.js b/src/server/es/index.js index 65ae4534..8ac91314 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -330,15 +330,16 @@ class ES { index: indicesArray, }).then((resp) => { try { - let indicesMetadata = resp.body; - for (var key in this.arrayFields) { - if(!indicesMetadata[key]) { - indicesMetadata[key] = {}; + const indicesMetadata = resp.body; + const keys = Object.keys(this.arrayFields); + for (let i = 0; i < keys.length; i += 1) { + if (!indicesMetadata[keys[i]]) { + indicesMetadata[keys[i]] = {}; } - indicesMetadata[key]["arrayFields"] = this.arrayFields[key]; + indicesMetadata[keys[i]].arrayFields = this.arrayFields[keys[i]]; } - indicesMetadata['fieldTypes'] = this.fieldTypes; - + indicesMetadata.fieldTypes = this.fieldTypes; + return { statusCode: resp.statusCode, warnings: resp.warnings, @@ -347,7 +348,6 @@ class ES { }, }; } catch (err) { - console.log('error: ', err); throw new Error(err); } }, (err) => { From 3d73a86717fc713887fdc0b451f9c2c7d3f294b0 Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Sun, 15 Nov 2020 14:04:43 -0600 Subject: [PATCH 7/9] chore: run eslint --- src/server/es/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index 8ac91314..718544ff 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -331,12 +331,13 @@ class ES { }).then((resp) => { try { const indicesMetadata = resp.body; - const keys = Object.keys(this.arrayFields); - for (let i = 0; i < keys.length; i += 1) { - if (!indicesMetadata[keys[i]]) { - indicesMetadata[keys[i]] = {}; + const indicesWithArrayFields = Object.keys(this.arrayFields); + for (let i = 0; i < indicesWithArrayFields.length; i += 1) { + const indexName = indicesWithArrayFields[i]; + if (!indicesMetadata[indexName]) { + indicesMetadata[indexName] = {}; } - indicesMetadata[keys[i]].arrayFields = this.arrayFields[keys[i]]; + indicesMetadata[indexName].arrayFields = this.arrayFields[indexName]; } indicesMetadata.fieldTypes = this.fieldTypes; From d8b42b3de093c300d1679c7b7afe566381834362 Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Mon, 16 Nov 2020 12:59:42 -0600 Subject: [PATCH 8/9] removing fieldTypes information --- src/server/es/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index 718544ff..827f0e13 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -339,7 +339,6 @@ class ES { } indicesMetadata[indexName].arrayFields = this.arrayFields[indexName]; } - indicesMetadata.fieldTypes = this.fieldTypes; return { statusCode: resp.statusCode, From f4a79dc19894b965c689d343b411b654586a1f67 Mon Sep 17 00:00:00 2001 From: Zakir Gowani Date: Mon, 16 Nov 2020 13:08:45 -0600 Subject: [PATCH 9/9] removing fieldTypes information --- src/server/es/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/server/es/index.js b/src/server/es/index.js index 827f0e13..a10019d7 100644 --- a/src/server/es/index.js +++ b/src/server/es/index.js @@ -339,7 +339,6 @@ class ES { } indicesMetadata[indexName].arrayFields = this.arrayFields[indexName]; } - return { statusCode: resp.statusCode, warnings: resp.warnings,