From 2df9435eb7abb877db6a9f112f501ea230f31bda Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 12 May 2024 17:33:36 +0800 Subject: [PATCH] elastic: support fuzzy matching --- packages/elastic/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/elastic/index.ts b/packages/elastic/index.ts index fb6973cac..0e347383b 100644 --- a/packages/elastic/index.ts +++ b/packages/elastic/index.ts @@ -27,7 +27,7 @@ global.Hydro.lib.problemSearch = async (domainId, q, opts) => { from, query: { simple_query_string: { - query: q, + query: q.replace(/([a-z0-9]{2,})/gi, (i) => `${i}~5`), fields: ['tag^5', 'pid^4', 'title^3', 'content'], }, },