索引搜索的权重相同的结果项按照修改时间新->旧排列。
This commit is contained in:
parent
6eecb71daf
commit
ffd72cbaba
|
@ -66,6 +66,7 @@ void ConstructDocumentForPath::run() {
|
||||||
doc.setUniqueTerm(uniqueterm);
|
doc.setUniqueTerm(uniqueterm);
|
||||||
doc.addTerm(upTerm);
|
doc.addTerm(upTerm);
|
||||||
doc.addValue(1, m_list.at(2));
|
doc.addValue(1, m_list.at(2));
|
||||||
|
doc.addSortableSerialiseValue(2, m_list.at(3));
|
||||||
/* QStringList temp;
|
/* QStringList temp;
|
||||||
// temp.append(index_text);
|
// temp.append(index_text);
|
||||||
temp.append(pinyin_text_list)*/;
|
temp.append(pinyin_text_list)*/;
|
||||||
|
|
|
@ -74,6 +74,11 @@ void Document::addValue(unsigned slot, QString value)
|
||||||
m_document.add_value(slot, value.toStdString());
|
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) {
|
void Document::setUniqueTerm(QString term) {
|
||||||
if(term.isEmpty())
|
if(term.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
void addTerm(QString term);
|
void addTerm(QString term);
|
||||||
void addTerm(std::string term);
|
void addTerm(std::string term);
|
||||||
void addValue(unsigned slot, QString value);
|
void addValue(unsigned slot, QString value);
|
||||||
|
void addSortableSerialiseValue(unsigned slot, QString value);
|
||||||
void setUniqueTerm(QString term);
|
void setUniqueTerm(QString term);
|
||||||
void setUniqueTerm(std::string term);
|
void setUniqueTerm(std::string term);
|
||||||
std::string getUniqueTerm();
|
std::string getUniqueTerm();
|
||||||
|
|
|
@ -56,7 +56,10 @@ FirstIndex::~FirstIndex() {
|
||||||
|
|
||||||
void FirstIndex::DoSomething(const QFileInfo& fileInfo) {
|
void FirstIndex::DoSomething(const QFileInfo& fileInfo) {
|
||||||
// qDebug() << "there are some shit here"<<fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0");
|
// 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)
|
if (fileInfo.fileName().split(".", QString::SkipEmptyParts).length() < 2)
|
||||||
return;
|
return;
|
||||||
if (true == targetFileTypeMap[fileInfo.fileName().split(".").last()]
|
if (true == targetFileTypeMap[fileInfo.fileName().split(".").last()]
|
||||||
|
|
|
@ -610,7 +610,9 @@ bool IndexGenerator::updateIndex(QVector<PendingFile> *pendingFiles)
|
||||||
deleteList->append(file.path());
|
deleteList->append(file.path());
|
||||||
continue;
|
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()){
|
if (file.path().split(".").isEmpty()){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,6 +143,8 @@ int FileSearch::keywordSearchfile() {
|
||||||
qDebug() << "keywordSearchfile:" << QString::fromStdString(queryFile.get_description());
|
qDebug() << "keywordSearchfile:" << QString::fromStdString(queryFile.get_description());
|
||||||
|
|
||||||
enquire.set_query(queryFile);
|
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);
|
Xapian::MSet result = enquire.get_mset(m_begin, m_num, 0, m_matchDecider);
|
||||||
int resultCount = result.size();
|
int resultCount = result.size();
|
||||||
qDebug() << "keywordSearchfile results count=" << resultCount;
|
qDebug() << "keywordSearchfile results count=" << resultCount;
|
||||||
|
@ -175,8 +177,10 @@ int FileSearch::getResult(Xapian::MSet &result) {
|
||||||
for(auto it = result.begin(); it != result.end(); ++it) {
|
for(auto it = result.begin(); it != result.end(); ++it) {
|
||||||
Xapian::Document doc = it.get_document();
|
Xapian::Document doc = it.get_document();
|
||||||
std::string data = doc.get_data();
|
std::string data = doc.get_data();
|
||||||
Xapian::weight docScoreWeight = it.get_weight();
|
// Xapian::weight docScoreWeight = it.get_weight();
|
||||||
Xapian::percent docScorePercent = it.get_percent();
|
// Xapian::percent docScorePercent = it.get_percent();
|
||||||
|
// std::string date = doc.get_value(2);
|
||||||
|
|
||||||
QString path = QString::fromStdString(data);
|
QString path = QString::fromStdString(data);
|
||||||
std::string().swap(data);
|
std::string().swap(data);
|
||||||
|
|
||||||
|
@ -208,7 +212,13 @@ int FileSearch::getResult(Xapian::MSet &result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//qDebug() << "doc=" << path << ",weight=" << docScoreWeight << ",percent=" << docScorePercent;
|
// qDebug() << "doc=" << path
|
||||||
|
// << ",weight="
|
||||||
|
// << docScoreWeight
|
||||||
|
// << ",percent="
|
||||||
|
// << docScorePercent
|
||||||
|
// << "date"
|
||||||
|
// << QString::fromStdString(date);
|
||||||
}
|
}
|
||||||
// if(!pathTobeDelete->isEmpty())
|
// if(!pathTobeDelete->isEmpty())
|
||||||
// deleteAllIndex(pathTobeDelete)
|
// deleteAllIndex(pathTobeDelete)
|
||||||
|
|
Loading…
Reference in New Issue