From f086bb5c46991195f7d2db18fc8024cacbd633a7 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 29 Jun 2023 13:19:59 -0700 Subject: [PATCH] use pelias-elasticsearch The legacy elasticsearch client had an integrated stdout logger. The new elasticsearch client does not, so instead we use the pelias-elasticsearch which integrates the modern elasticsearch client with pelias-logger. --- package.json | 2 +- scripts/check_plugins.js | 4 ++-- scripts/check_version.js | 4 ++-- scripts/create_index.js | 4 ++-- scripts/drop_index.js | 5 ++--- scripts/info.js | 4 ++-- scripts/update_settings.js | 4 ++-- 7 files changed, 13 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 467c340e..c66c35ca 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "@hapi/joi": "^16.1.8", "colors": "^1.1.2", - "@elastic/elasticsearch": "~7.17.0", + "pelias-elasticsearch": "https://github.com/michaelkirk-pelias/pelias-elasticsearch#mkirk\/elastic8", "glob": "^7.1.6", "lodash": "^4.17.15", "pelias-config": "https://github.com/michaelkirk-pelias/config#mkirk\/elastic8", diff --git a/scripts/check_plugins.js b/scripts/check_plugins.js index ac7a2aa2..8b23db65 100644 --- a/scripts/check_plugins.js +++ b/scripts/check_plugins.js @@ -1,7 +1,7 @@ const colors = require('colors/safe'); const config = require('pelias-config').generate(); -const es = require('@elastic/elasticsearch'); -const client = new es.Client(config.esclient); +const buildClient = require('pelias-elasticsearch'); +const client = buildClient(config.esclient); const cli = require('./cli'); // mandatory plugins diff --git a/scripts/check_version.js b/scripts/check_version.js index 9e0d76b6..77e0894d 100644 --- a/scripts/check_version.js +++ b/scripts/check_version.js @@ -1,8 +1,8 @@ const _ = require('lodash'); const semver = require('semver'); -const es = require('@elastic/elasticsearch'); +const buildClient = require('pelias-elasticsearch'); const config = require('pelias-config').generate(); -const client = new es.Client(config.esclient); +const client = buildClient(config.esclient); const cli = require('./cli'); // pass target elastic version semver as the first CLI arg diff --git a/scripts/create_index.js b/scripts/create_index.js index 93b68b57..9cca702f 100644 --- a/scripts/create_index.js +++ b/scripts/create_index.js @@ -1,6 +1,6 @@ const child_process = require('child_process'); const config = require('pelias-config').generate(); -const es = require('@elastic/elasticsearch'); +const buildClient = require('pelias-elasticsearch'); const SUPPORTED_ES_VERSIONS = '>=7.4.2'; const cli = require('./cli'); @@ -8,7 +8,7 @@ const schema = require('../schema'); cli.header("create index"); -const client = new es.Client(config.esclient); +const client = buildClient(config.esclient); // check minimum elasticsearch versions before continuing try { diff --git a/scripts/drop_index.js b/scripts/drop_index.js index 0fd3c655..f82d253b 100644 --- a/scripts/drop_index.js +++ b/scripts/drop_index.js @@ -1,7 +1,7 @@ const colors = require('colors/safe'); const config = require('pelias-config').generate(); -const es = require('@elastic/elasticsearch'); -const client = new es.Client(config.esclient); +const buildClient = require('pelias-elasticsearch'); +const client = buildClient(config.esclient); const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); @@ -20,7 +20,6 @@ function drop() { // check all hosts to see if any is not localhost function warnIfNotLocal() { for (const idx in config.esclient.nodes) { - debugger; const node = config.esclient.nodes[idx]; if (!node.includes('://localhost')) { console.log(colors.red(`WARNING: DROPPING SCHEMA NOT ON LOCALHOST: ${node}`)); diff --git a/scripts/info.js b/scripts/info.js index 62504c6e..26d0788b 100644 --- a/scripts/info.js +++ b/scripts/info.js @@ -1,5 +1,5 @@ var config = require('pelias-config').generate().esclient; -var es = require('@elastic/elasticsearch'); -var client = new es.Client(config); +var buildClient = require('pelias-elasticsearch'); +var client = buildClient(config); client.info( {}, console.log.bind(console) ); diff --git a/scripts/update_settings.js b/scripts/update_settings.js index b2ae69b8..1dbdd633 100644 --- a/scripts/update_settings.js +++ b/scripts/update_settings.js @@ -1,6 +1,6 @@ var config = require('pelias-config').generate(); -var es = require('@elastic/elasticsearch'); -var client = new es.Client(config.esclient); +var buildClient = require('pelias-elasticsearch'); +var client = buildClient(config.esclient); var schema = require('../schema'); var _index = config.schema.indexName;