shared: sqlitesearch: Only order by rank if token is FILTER_CONTENT_CONTAINS

This commit is contained in:
Albert S. 2022-04-17 21:15:58 +02:00
rodzic 2a024a9b40
commit 8194476fa6

Wyświetl plik

@ -133,7 +133,8 @@ QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
throw LooqsGeneralException("Nothing to search for supplied");
}
for(const Token &token : query.getTokens())
auto tokens = query.getTokens();
for(const Token &token : tokens)
{
if(token.type == FILTER_CONTENT_CONTAINS)
{
@ -155,7 +156,11 @@ QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
{
if(sortSql.isEmpty())
{
sortSql = "ORDER BY rank";
if(std::find_if(tokens.begin(), tokens.end(),
[](const Token &t) -> bool { return t.type == FILTER_CONTENT_CONTAINS; }) != tokens.end())
{
sortSql = "ORDER BY rank";
}
}
prepSql =
"SELECT file.path AS path, group_concat(content.page) AS pages, file.mtime AS mtime, file.size AS size, "