From 10bfb512159f34c12ea9cf8a6948fa20a970a1b0 Mon Sep 17 00:00:00 2001 From: wiz Date: Thu, 23 Feb 2023 13:37:09 +0900 Subject: [PATCH] Add simon's comment to $searchNodeByPublicKeyOrAlias() --- backend/src/api/explorer/nodes.api.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/api/explorer/nodes.api.ts b/backend/src/api/explorer/nodes.api.ts index 36bbf26d2..b3f83faa6 100644 --- a/backend/src/api/explorer/nodes.api.ts +++ b/backend/src/api/explorer/nodes.api.ts @@ -368,6 +368,7 @@ class NodesApi { .split(' ') .filter(key => key.length) .map((search) => '+' + search + '*').join(' '); + // %keyword% is wildcard search and can't be indexed so it's slower as the node database grow. keyword% can be indexed but then you can't search for "Nicehash" and get result for ln.nicehash.com. So we use fulltext index for words "ln, nicehash, com" and nicehash* will find it instantly. const query = `SELECT public_key, alias, capacity, channels, status FROM nodes WHERE public_key LIKE ? OR MATCH alias_search AGAINST (? IN BOOLEAN MODE) ORDER BY capacity DESC LIMIT 10`; const [rows]: any = await DB.query(query, [publicKeySearch, aliasSearch]); return rows;