From 0f152ab2bba72c339eaefd0d67ec5a27c16f2ab4 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Thu, 4 Jun 2026 02:38:00 +0900 Subject: [PATCH] search/word_search: score matching kana higher than converted kana --- lib/search/word_search/entry_id_query.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/search/word_search/entry_id_query.dart b/lib/search/word_search/entry_id_query.dart index a939aee..a5e445d 100644 --- a/lib/search/word_search/entry_id_query.dart +++ b/lib/search/word_search/entry_id_query.dart @@ -67,25 +67,28 @@ String _filterFTSSensitiveCharacters(String word) { SELECT DISTINCT "$tableName"."entryId", 100 - + (("${tableName}FTS"."reading" = normalize_jp(?)) * 10000) + + (("$tableName"."reading" = ?1) * 100000) + + (("${tableName}FTS"."reading" = normalize_jp(?1)) * 10000) + + (("$tableName"."reading" LIKE ?1 || '%') * 20) + (("$tableName"."orderNum" = 0) * 20) + COALESCE("JMdict_EntryScore"."score", 0) AS "score" FROM "${tableName}FTS" JOIN "$tableName" USING ("elementId") LEFT JOIN "JMdict_EntryScore" USING ("elementId") - WHERE "${tableName}FTS"."reading" MATCH normalize_jp(?) || '*' + WHERE "${tableName}FTS"."reading" MATCH normalize_jp(?1) || '*' ), non_fts_results AS ( SELECT DISTINCT "$tableName"."entryId", 50 + + (("$tableName"."reading" LIKE '%' || ?1 || '%') * 20) + (("$tableName"."orderNum" = 0) * 20) + COALESCE("JMdict_EntryScore"."score", 0) AS "score" FROM "$tableName" LEFT JOIN "JMdict_EntryScore" USING ("elementId") - WHERE "reading" LIKE '%' || normalize_jp(?) || '%' + WHERE "$tableName"."reading" LIKE '%' || normalize_jp(?1) || '%' AND "$tableName"."entryId" NOT IN (SELECT "entryId" FROM "fts_results") ) @@ -102,8 +105,6 @@ String _filterFTSSensitiveCharacters(String word) { ''' .trim(), [ - _filterFTSSensitiveCharacters(word), - _filterFTSSensitiveCharacters(word), _filterFTSSensitiveCharacters(word), ?pageSize, ?offset,