word_search: always order exact matches first
This commit is contained in:
@@ -53,7 +53,7 @@ String _filterFTSSensitiveCharacters(String word) {
|
||||
SELECT DISTINCT
|
||||
"${tableName}"."entryId",
|
||||
100
|
||||
+ (("${tableName}FTS"."reading" = ?) * 50)
|
||||
+ (("${tableName}FTS"."reading" = ?) * 10000)
|
||||
+ "JMdict_EntryScore"."score"
|
||||
AS "score"
|
||||
FROM "${tableName}FTS"
|
||||
@@ -61,8 +61,6 @@ String _filterFTSSensitiveCharacters(String word) {
|
||||
JOIN "JMdict_EntryScore" USING ("elementId")
|
||||
WHERE "${tableName}FTS"."reading" MATCH ? || '*'
|
||||
AND "JMdict_EntryScore"."type" = '${tableName == JMdictTableNames.kanjiElement ? 'k' : 'r'}'
|
||||
ORDER BY
|
||||
"JMdict_EntryScore"."score" DESC
|
||||
${!countOnly ? 'LIMIT ?' : ''}
|
||||
),
|
||||
non_fts_results AS (
|
||||
@@ -76,9 +74,6 @@ String _filterFTSSensitiveCharacters(String word) {
|
||||
WHERE "reading" LIKE '%' || ? || '%'
|
||||
AND "${tableName}"."entryId" NOT IN (SELECT "entryId" FROM "fts_results")
|
||||
AND "JMdict_EntryScore"."type" = '${tableName == JMdictTableNames.kanjiElement ? 'k' : 'r'}'
|
||||
ORDER BY
|
||||
"JMdict_EntryScore"."score" DESC,
|
||||
"${tableName}"."entryId" ASC
|
||||
${!countOnly ? 'LIMIT ?' : ''}
|
||||
)
|
||||
|
||||
@@ -89,6 +84,9 @@ String _filterFTSSensitiveCharacters(String word) {
|
||||
SELECT * FROM non_fts_results
|
||||
)
|
||||
GROUP BY "entryId"
|
||||
ORDER BY
|
||||
"score" DESC,
|
||||
"entryId" ASC
|
||||
'''
|
||||
.trim(),
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user