Merge branch 'ukss-dev' into 'ukss-dev'

索引搜索的权重相同的结果项按照修改时间新->旧排列。

See merge request kylin-desktop/ukui-search!293
This commit is contained in:
纪笑旭 2022-04-19 01:18:32 +00:00
commit 3fd06b9569
6 changed files with 27 additions and 5 deletions

View File

@ -66,6 +66,7 @@ void ConstructDocumentForPath::run() {
doc.setUniqueTerm(uniqueterm);
doc.addTerm(upTerm);
doc.addValue(1, m_list.at(2));
doc.addSortableSerialiseValue(2, m_list.at(3));
/* QStringList temp;
// temp.append(index_text);
temp.append(pinyin_text_list)*/;

View File

@ -74,6 +74,11 @@ void Document::addValue(unsigned slot, QString value)
m_document.add_value(slot, value.toStdString());
}
void Document::addSortableSerialiseValue(unsigned slot, QString value)
{
m_document.add_value(slot, Xapian::sortable_serialise(value.toDouble()));
}
void Document::setUniqueTerm(QString term) {
if(term.isEmpty())
return;

View File

@ -48,6 +48,7 @@ public:
void addTerm(QString term);
void addTerm(std::string term);
void addValue(unsigned slot, QString value);
void addSortableSerialiseValue(unsigned slot, QString value);
void setUniqueTerm(QString term);
void setUniqueTerm(std::string term);
std::string getUniqueTerm();

View File

@ -56,7 +56,10 @@ FirstIndex::~FirstIndex() {
void FirstIndex::DoSomething(const QFileInfo& fileInfo) {
// qDebug() << "there are some shit here"<<fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0");
this->m_indexData->enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0"));
this->m_indexData->enqueue(QVector<QString>() << fileInfo.fileName()
<< fileInfo.absoluteFilePath()
<< QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0")
<< fileInfo.lastModified().toString("yyyyMMddHHmmss"));
if (fileInfo.fileName().split(".", QString::SkipEmptyParts).length() < 2)
return;
if (true == targetFileTypeMap[fileInfo.fileName().split(".").last()]

View File

@ -610,7 +610,9 @@ bool IndexGenerator::updateIndex(QVector<PendingFile> *pendingFiles)
deleteList->append(file.path());
continue;
}
fileIndexInfo->append(QVector<QString>() << file.path().section("/" , -1) << file.path() << QString(file.isDir() ? "1" : "0"));
fileIndexInfo->append(QVector<QString>() << file.path().section("/" , -1)
<< file.path() << QString(file.isDir() ? "1" : "0")
<< QFileInfo(file.path()).lastModified().toString("yyyyMMddHHmmss"));
if (file.path().split(".").isEmpty()){
continue;
}

View File

@ -143,6 +143,8 @@ int FileSearch::keywordSearchfile() {
qDebug() << "keywordSearchfile:" << QString::fromStdString(queryFile.get_description());
enquire.set_query(queryFile);
enquire.set_docid_order(enquire.DONT_CARE);
enquire.set_sort_by_relevance_then_value(2, true);
Xapian::MSet result = enquire.get_mset(m_begin, m_num, 0, m_matchDecider);
int resultCount = result.size();
qDebug() << "keywordSearchfile results count=" << resultCount;
@ -175,8 +177,10 @@ int FileSearch::getResult(Xapian::MSet &result) {
for(auto it = result.begin(); it != result.end(); ++it) {
Xapian::Document doc = it.get_document();
std::string data = doc.get_data();
Xapian::weight docScoreWeight = it.get_weight();
Xapian::percent docScorePercent = it.get_percent();
// Xapian::weight docScoreWeight = it.get_weight();
// Xapian::percent docScorePercent = it.get_percent();
// std::string date = doc.get_value(2);
QString path = QString::fromStdString(data);
std::string().swap(data);
@ -208,7 +212,13 @@ int FileSearch::getResult(Xapian::MSet &result) {
break;
}
}
//qDebug() << "doc=" << path << ",weight=" << docScoreWeight << ",percent=" << docScorePercent;
// qDebug() << "doc=" << path
// << ",weight="
// << docScoreWeight
// << ",percent="
// << docScorePercent
// << "date"
// << QString::fromStdString(date);
}
// if(!pathTobeDelete->isEmpty())
// deleteAllIndex(pathTobeDelete)