[FIX] File search won't return enough result issue.

This commit is contained in:
zhangzihao 2021-01-26 16:50:30 +08:00
parent 9845fdd3bf
commit fccf8a25ef
2 changed files with 39 additions and 45 deletions

View File

@ -58,7 +58,7 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResult
int num = 5;
int resultCount = 0;
int total = 0;
while(total<20)
while(total < 100)
{
resultCount = keywordSearchfile(uniqueSymbol1,keyword,"0",1,begin,num);
if(resultCount == 0 || resultCount == -1)
@ -77,7 +77,7 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResult
int num = 5;
int resultCount = 0;
int total = 0;
while(total<20)
while(total<100)
{
resultCount = keywordSearchfile(uniqueSymbol2,keyword,"1",1,begin,num);
if(resultCount == 0 || resultCount == -1)
@ -97,7 +97,7 @@ void FileSearcher::onKeywordSearch(QString keyword,QQueue<QString> *searchResult
int resultCount = 0;
int total = 0;
while(total<20)
while(total<50)
{
resultCount = keywordSearchContent(uniqueSymbol3,keyword,begin,num);
if(resultCount == 0 || resultCount == -1)
@ -134,8 +134,8 @@ int FileSearcher::keywordSearchfile(size_t uniqueSymbol, QString keyword, QStrin
qDebug() << "keywordSearchfile:"<<QString::fromStdString(queryFile.get_description());
enquire.set_query(queryFile);
Xapian::MSet result = enquire.get_mset(begin, begin+num);
int resultCount = static_cast<int>(result.get_matches_estimated());
Xapian::MSet result = enquire.get_mset(begin, num);
int resultCount = result.size();
qDebug()<< "keywordSearchfile results count=" <<resultCount;
if(result.size() == 0)
return 0;
@ -185,8 +185,8 @@ int FileSearcher::keywordSearchContent(size_t uniqueSymbol, QString keyword, int
enquire.set_query(query);
Xapian::MSet result = enquire.get_mset(begin, begin+num);
int resultCount = static_cast<int>(result.get_matches_estimated());
Xapian::MSet result = enquire.get_mset(begin, num);
int resultCount = result.size();
if(result.size() == 0)
return 0;
qDebug()<< "keywordSearchContent results count=" <<resultCount;

View File

@ -126,15 +126,9 @@ IndexGenerator::IndexGenerator(bool rebuild, QObject *parent) : QObject(parent)
database.setPath(QString::fromStdString(CONTENT_INDEX_PATH));
if(database.exists())
database.removeRecursively();
m_database_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OVERWRITE);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OVERWRITE);
}
else
{
m_database_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
}
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"0");
}