From 5bbd4ae703f12b20e1f308f430b65f9e30bfff21 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 20 Mar 2020 14:00:34 +0900 Subject: [PATCH] =?UTF-8?q?ElasticSearch=E3=81=A7=E8=AA=8D=E8=A8=BC?= =?UTF-8?q?=E3=81=8C=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#6158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/example.yml | 4 +++- src/config/types.ts | 5 +++-- src/db/elasticsearch.ts | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.config/example.yml b/.config/example.yml index 91580d9ecb..201082cce9 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -88,7 +88,9 @@ redis: #elasticsearch: # host: localhost # port: 9200 -# pass: null +# ssl: false +# user: +# pass: # ┌───────────────┐ #───┘ ID generation └─────────────────────────────────────────── diff --git a/src/config/types.ts b/src/config/types.ts index 78ae025133..a33901bde6 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -27,9 +27,10 @@ export type Source = { elasticsearch: { host: string; port: number; - pass: string; - index?: string; ssl?: boolean; + user?: string; + pass?: string; + index?: string; }; proxy?: string; diff --git a/src/db/elasticsearch.ts b/src/db/elasticsearch.ts index b62e17461a..048e399bdf 100644 --- a/src/db/elasticsearch.ts +++ b/src/db/elasticsearch.ts @@ -33,6 +33,10 @@ const index = { // Init ElasticSearch connection const client = config.elasticsearch ? new elasticsearch.Client({ node: `${config.elasticsearch.ssl ? 'https://' : 'http://'}${config.elasticsearch.host}:${config.elasticsearch.port}`, + auth: (config.elasticsearch.user && config.elasticsearch.pass) ? { + username: config.elasticsearch.user, + password: config.elasticsearch.pass + } : undefined, pingTimeout: 30000 }) : null;