Add simon's comment to $searchNodeByPublicKeyOrAlias()

This commit is contained in:
wiz 2023-02-23 13:37:09 +09:00
parent 03be3ab561
commit 10bfb51215
No known key found for this signature in database
GPG key ID: A394E332255A6173

View file

@ -368,6 +368,7 @@ class NodesApi {
.split(' ') .split(' ')
.filter(key => key.length) .filter(key => key.length)
.map((search) => '+' + search + '*').join(' '); .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 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]); const [rows]: any = await DB.query(query, [publicKeySearch, aliasSearch]);
return rows; return rows;