From 84a1e6d6ad16d1610786e34027cc460f6471000e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Holp?= Date: Wed, 8 Apr 2020 16:30:45 +0000 Subject: [PATCH] Upload files to 'pages/students/2016/jan_holp/dp2021/zdrojove_subory' skript na kontrolu indexovanych dat --- .../dp2021/zdrojove_subory/indices.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pages/students/2016/jan_holp/dp2021/zdrojove_subory/indices.js diff --git a/pages/students/2016/jan_holp/dp2021/zdrojove_subory/indices.js b/pages/students/2016/jan_holp/dp2021/zdrojove_subory/indices.js new file mode 100644 index 000000000..10fd4833c --- /dev/null +++ b/pages/students/2016/jan_holp/dp2021/zdrojove_subory/indices.js @@ -0,0 +1,28 @@ +(function () { + 'use strict'; + + const elasticsearch = require('elasticsearch'); + const esClient = new elasticsearch.Client({ + host: '127.0.0.1:9200', + log: 'error' + }); + + const indices = function indices() { + return esClient.cat.indices({v: true}) + .then(console.log) + .catch(err => console.error(`Error connecting to the es client: ${err}`)); + }; + + // only for testing purposes + // all calls should be initiated through the module + const test = function test() { + console.log(`elasticsearch indices information:`); + indices(); + }; + + test(); + + module.exports = { + indices + }; +} ());