From 24a91229f28fb17cb4941aab688a08266437c1eb Mon Sep 17 00:00:00 2001 From: Rainer Killinger Date: Tue, 28 Jul 2020 15:11:20 +0200 Subject: [PATCH] fix: enhance default search query generation --- config/elasticsearch.ts | 8 ++++++++ src/storage/elasticsearch/common.ts | 2 +- src/storage/elasticsearch/query.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/elasticsearch.ts b/config/elasticsearch.ts index f82002d2..27d0d6d5 100644 --- a/config/elasticsearch.ts +++ b/config/elasticsearch.ts @@ -20,6 +20,14 @@ const config: ElasticsearchConfigFile = { database: { name: 'elasticsearch', version: '5.6', + query: { + minMatch: '75%', + queryType: 'dis_max', + matchBoosting: 1.3, + fuzziness: 'AUTO', + cutoffFrequency: 0.0, + tieBreaker: 0, + }, }, }, }; diff --git a/src/storage/elasticsearch/common.ts b/src/storage/elasticsearch/common.ts index 61125869..f7a664f3 100644 --- a/src/storage/elasticsearch/common.ts +++ b/src/storage/elasticsearch/common.ts @@ -135,7 +135,7 @@ export interface ElasticsearchQueryDisMaxConfig { * The maximum allowed Levenshtein Edit Distance (or number of edits) * @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-options.html#fuzziness */ - fuzziness: number; + fuzziness: number | string; /** * Increase the importance (relevance score) of a field diff --git a/src/storage/elasticsearch/query.ts b/src/storage/elasticsearch/query.ts index 7ea19af0..18b6bf94 100644 --- a/src/storage/elasticsearch/query.ts +++ b/src/storage/elasticsearch/query.ts @@ -347,7 +347,7 @@ export function buildQuery( query_string: { analyzer: 'search_german', default_field: 'name', - minimum_should_match: elasticsearchConfig.query.fuzziness, + minimum_should_match: elasticsearchConfig.query.minMatch, query: (typeof params.query !== 'string') ? '*' : escapeESReservedCharacters(params.query), }, },