From 1b92ec0443eddbde954a4de50f30ab7ef6f3cda2 Mon Sep 17 00:00:00 2001 From: MomentQYC Date: Mon, 5 Feb 2024 13:30:46 +0800 Subject: [PATCH] feat: Supports both tokenization by Elasticsearch analyzers and handling of nonsensical strings --- packages/backend/src/core/SearchService.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/SearchService.ts b/packages/backend/src/core/SearchService.ts index 452aef068f..f5a09b0160 100644 --- a/packages/backend/src/core/SearchService.ts +++ b/packages/backend/src/core/SearchService.ts @@ -301,7 +301,15 @@ export class SearchService { query: { bool: { must: [ - { wildcard: { "text": { value: `*${q}*` }, } }, + { + bool: { + should: [ + { wildcard: { "text": { value: `*${q}*` }, } }, + { simple_query_string: { fields:["text"], "query": q, default_operator: 'and', } }, + ], + minimum_should_match: 1, + }, + }, esFilter, ] },