migrations: combine score tables
This commit is contained in:
@@ -41,28 +41,31 @@ SearchMode _determineSearchMode(String word) {
|
||||
"${tableName}FTS"."entryId",
|
||||
100
|
||||
+ (("${tableName}FTS"."reading" = ?) * 50)
|
||||
+ "${tableName}Score"."score"
|
||||
+ "JMdict_EntryScore"."score"
|
||||
AS "score"
|
||||
FROM "${tableName}FTS"
|
||||
JOIN "${tableName}" USING ("entryId", "reading")
|
||||
JOIN "${tableName}Score" USING ("entryId", "reading")
|
||||
JOIN "JMdict_EntryScore" USING ("entryId", "reading")
|
||||
WHERE "${tableName}FTS"."reading" MATCH ? || '*'
|
||||
ORDER BY "score" DESC
|
||||
AND "JMdict_EntryScore"."type" = '${tableName == JMdictTableNames.kanjiElement ? 'kanji' : 'reading'}'
|
||||
ORDER BY
|
||||
"JMdict_EntryScore"."score" DESC
|
||||
${!countOnly ? 'LIMIT ?' : ''}
|
||||
),
|
||||
non_fts_results AS (
|
||||
SELECT DISTINCT
|
||||
"entryId",
|
||||
"${tableName}"."entryId",
|
||||
50
|
||||
+ "${tableName}Score"."score"
|
||||
+ "JMdict_EntryScore"."score"
|
||||
AS "score"
|
||||
FROM "${tableName}"
|
||||
JOIN "${tableName}Score" USING ("entryId", "reading")
|
||||
JOIN "JMdict_EntryScore" USING ("entryId", "reading")
|
||||
WHERE "reading" LIKE '%' || ? || '%'
|
||||
AND "entryId" NOT IN (SELECT "entryId" FROM "fts_results")
|
||||
AND "JMdict_EntryScore"."type" = '${tableName == JMdictTableNames.kanjiElement ? 'kanji' : 'reading'}'
|
||||
ORDER BY
|
||||
"score" DESC,
|
||||
"entryId" ASC
|
||||
"JMdict_EntryScore"."score" DESC,
|
||||
"${tableName}"."entryId" ASC
|
||||
${!countOnly ? 'LIMIT ?' : ''}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user