shared,gui,cli: Fix intra-file ordering for content search results

group_concat() does not preserve order of the ORDRE BY rank,
making the ordering quite meaningless for pages inside a file.

The recently introduced combobox to filter on a per file basis
should anyway be prefered than any kind of grouping in queries.

So we just remove the groupings here.

"All files" in the previews tab thus should show the best results
first now, from any files part of the result set.

A GUI option to sort by page instead of rank can be considered.
This commit is contained in:
Albert S. 2022-08-23 23:30:10 +02:00
szülő d8205a0da4
commit eef0fae137
3 fájl változott, egészen pontosan 28 új sor hozzáadva és 15 régi sor törölve

Fájl megtekintése

@ -33,11 +33,18 @@ int CommandSearch::handle(QStringList arguments)
try
{
QHash<QString, bool> seenMap;
auto results = dbService->search(query);
for(SearchResult &result : results)
for(const SearchResult &result : results)
{
Logger::info() << result.fileData.absPath << Qt::endl;
const QString &absPath = result.fileData.absPath;
if(!seenMap.contains(absPath))
{
seenMap[absPath] = true;
Logger::info() << absPath << Qt::endl;
}
}
}
catch(LooqsGeneralException &e)

Fájl megtekintése

@ -808,19 +808,25 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
ui->comboPreviewFiles->setVisible(true);
bool hasDeleted = false;
QHash<QString, bool> seenMap;
for(const SearchResult &result : results)
{
QFileInfo pathInfo(result.fileData.absPath);
const QString &absPath = result.fileData.absPath;
QFileInfo pathInfo(absPath);
QString fileName = pathInfo.fileName();
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeResultsList);
if(!seenMap.contains(absPath))
{
seenMap[absPath] = true;
QString fileName = pathInfo.fileName();
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeResultsList);
QDateTime dt = QDateTime::fromSecsSinceEpoch(result.fileData.mtime);
item->setIcon(0, iconProvider.icon(pathInfo));
item->setText(0, fileName);
item->setText(1, result.fileData.absPath);
item->setText(2, dt.toString(Qt::ISODate));
item->setText(3, this->locale().formattedDataSize(result.fileData.size));
QDateTime dt = QDateTime::fromSecsSinceEpoch(result.fileData.mtime);
item->setIcon(0, iconProvider.icon(pathInfo));
item->setText(0, fileName);
item->setText(1, absPath);
item->setText(2, dt.toString(Qt::ISODate));
item->setText(3, this->locale().formattedDataSize(result.fileData.size));
}
bool exists = pathInfo.exists();
if(exists)
{
@ -843,6 +849,7 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
hasDeleted = true;
}
}
ui->treeResultsList->resizeColumnToContents(0);
ui->treeResultsList->resizeColumnToContents(1);
ui->treeResultsList->resizeColumnToContents(2);

Fájl megtekintése

@ -194,10 +194,9 @@ QSqlQuery SqliteSearch::makeSqlQuery(const LooqsQuery &query)
sortSql = "ORDER BY rank";
}
}
prepSql =
"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 " +
joinSql + " WHERE 1=1 AND " + whereSql + " GROUP BY file.path " + sortSql;
prepSql = "SELECT file.path AS path, 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 " +
joinSql + " WHERE 1=1 AND " + whereSql + " " + sortSql;
}
else
{