From 1c273a0a756a71984c51966dccc7c0f48b1737b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=92=8C=E9=A2=A8=E3=83=89=E3=83=AC=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=B3=E3=82=B0?= <37681609+CookieRamen@users.noreply.github.com> Date: Fri, 9 Aug 2019 13:04:35 +0900 Subject: [PATCH] =?UTF-8?q?Elasticsearch=E3=81=AE=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=87=E3=83=83=E3=82=AF=E3=82=B9=E5=90=8D=E3=82=92config?= =?UTF-8?q?=E3=81=A7=E5=A4=89=E6=9B=B4=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=20(#5257)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/types.ts | 1 + src/db/elasticsearch.ts | 4 ++-- src/server/api/endpoints/notes/search.ts | 3 ++- src/services/note/create.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/config/types.ts b/src/config/types.ts index be3575d28..9ecf495c4 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -28,6 +28,7 @@ export type Source = { host: string; port: number; pass: string; + index?: string; }; autoAdmin?: boolean; diff --git a/src/db/elasticsearch.ts b/src/db/elasticsearch.ts index 02c9e88d9..b34ebe605 100644 --- a/src/db/elasticsearch.ts +++ b/src/db/elasticsearch.ts @@ -38,11 +38,11 @@ const client = config.elasticsearch ? new elasticsearch.Client({ if (client) { client.indices.exists({ - index: 'misskey_note' + index: config.elasticsearch.index || 'misskey_note', }).then(exist => { if (!exist.body) { client.indices.create({ - index: 'misskey_note', + index: config.elasticsearch.index || 'misskey_note', body: index }); } diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index d3fb33c42..5557b469e 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -5,6 +5,7 @@ import { ApiError } from '../../error'; import { Notes } from '../../../../models'; import { In } from 'typeorm'; import { ID } from '../../../../misc/cafy-id'; +import config from '../../../../config'; export const meta = { desc: { @@ -87,7 +88,7 @@ export default define(meta, async (ps, me) => { : []; const result = await es.search({ - index: 'misskey_note', + index: config.elasticsearch.index || 'misskey_note', body: { size: ps.limit!, from: ps.offset, diff --git a/src/services/note/create.ts b/src/services/note/create.ts index c38eb1898..48d867022 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -434,7 +434,7 @@ function index(note: Note) { if (note.text == null || config.elasticsearch == null) return; es!.index({ - index: 'misskey_note', + index: config.elasticsearch.index || 'misskey_note', id: note.id.toString(), body: { text: note.text.toLowerCase(),