shared: sqlitesearch: Order by rank by default for content search

Making ranked results the default makes (obviously) more sense for
content search.
This commit is contained in:
Albert S. 2020-12-19 12:42:28 +01:00
parent 344eaa402e
commit 0cba6f3fa4

View File

@ -115,7 +115,8 @@ QPair<QString, QVector<QString>> SqliteSearch::createSql(const Token &token)
} }
if(token.type == FILTER_CONTENT_CONTAINS) if(token.type == FILTER_CONTENT_CONTAINS)
{ {
return {" content.id IN (SELECT content_fts.ROWID FROM content_fts WHERE content_fts.content MATCH ?) ", return {" content.id IN (SELECT content_fts.ROWID FROM content_fts WHERE content_fts.content MATCH ? ORDER BY "
"rank) ",
{value}}; {value}};
} }
throw QSSGeneralException("Unknown token passed (should not happen)"); throw QSSGeneralException("Unknown token passed (should not happen)");
@ -142,10 +143,6 @@ QSqlQuery SqliteSearch::makeSqlQuery(const QSSQuery &query)
QString sortSql = createSortSql(query.getSortConditions()); QString sortSql = createSortSql(query.getSortConditions());
if(isContentSearch) if(isContentSearch)
{ {
if(sortSql.isEmpty())
{
sortSql = "ORDER BY file.mtime DESC, content.page ASC";
}
prepSql = prepSql =
"SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, " "SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, "
"file.filetype AS filetype FROM file INNER JOIN content ON file.id = content.fileid WHERE 1=1 AND " + "file.filetype AS filetype FROM file INNER JOIN content ON file.id = content.fileid WHERE 1=1 AND " +