mirror of https://github.com/kiwix/libkiwix.git
+ better search results
This commit is contained in:
parent
5056c59747
commit
ef3202dc02
|
@ -127,16 +127,17 @@ namespace kiwix {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count words */
|
/* count words */
|
||||||
stringstream st;
|
stringstream countWordStringStream;
|
||||||
st << countWords(this->htmlParser.dump);
|
countWordStringStream << countWords(this->htmlParser.dump);
|
||||||
const std::string wordCountString = st.str();
|
const std::string wordCountString = countWordStringStream.str();
|
||||||
|
|
||||||
/* snippet */
|
/* snippet */
|
||||||
const std::string snippet = std::string(this->htmlParser.dump, 0, 300);
|
const std::string snippet = std::string(this->htmlParser.dump, 0, 300);
|
||||||
|
|
||||||
/* size */
|
/* size */
|
||||||
st << content.size();
|
stringstream sizeStringStream;
|
||||||
const std::string size = st.str();
|
sizeStringStream << content.size() / 1024;
|
||||||
|
const std::string size = sizeStringStream.str();
|
||||||
|
|
||||||
this->indexNextArticle(url,
|
this->indexNextArticle(url,
|
||||||
accentedTitle,
|
accentedTitle,
|
||||||
|
|
|
@ -24,7 +24,8 @@ namespace kiwix {
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
Searcher::Searcher() :
|
Searcher::Searcher() :
|
||||||
estimatedResultCount(0),
|
estimatedResultCount(0),
|
||||||
resultTemplatePath("") {
|
resultTemplatePath(""),
|
||||||
|
searchPattern("") {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search strings in the database */
|
/* Search strings in the database */
|
||||||
|
@ -36,6 +37,7 @@ namespace kiwix {
|
||||||
cout << "Performing query `" << search << "'" << endl;
|
cout << "Performing query `" << search << "'" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->searchPattern = search;
|
||||||
searchInIndex(removeAccents(search), resultsCount, verbose);
|
searchInIndex(removeAccents(search), resultsCount, verbose);
|
||||||
this->resultOffset = this->results.begin();
|
this->resultOffset = this->results.begin();
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ namespace kiwix {
|
||||||
this->results.clear();
|
this->results.clear();
|
||||||
this->resultOffset = this->results.begin();
|
this->resultOffset = this->results.begin();
|
||||||
this->estimatedResultCount = 0;
|
this->estimatedResultCount = 0;
|
||||||
|
this->searchPattern = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +148,7 @@ namespace kiwix {
|
||||||
|
|
||||||
oData["results"] = resultsCDT;
|
oData["results"] = resultsCDT;
|
||||||
oData["count"] = this->estimatedResultCount;
|
oData["count"] = this->estimatedResultCount;
|
||||||
|
oData["searchPattern"] = this->searchPattern;
|
||||||
|
|
||||||
STLW::string sResult;
|
STLW::string sResult;
|
||||||
StringOutputCollector oDataCollector(sResult);
|
StringOutputCollector oDataCollector(sResult);
|
||||||
|
|
|
@ -77,6 +77,7 @@ namespace kiwix {
|
||||||
std::vector<Result>::iterator resultOffset;
|
std::vector<Result>::iterator resultOffset;
|
||||||
std::string resultTemplatePath;
|
std::string resultTemplatePath;
|
||||||
unsigned int estimatedResultCount;
|
unsigned int estimatedResultCount;
|
||||||
|
std::string searchPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
Results <b>1-20</b> of <b><TMPL_var count></b> for <b>Paris</b>
|
Results <b>1-20</b> of <b><TMPL_var count></b> for <b><TMPL_var searchPattern></b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="results">
|
<div class="results">
|
||||||
|
|
Loading…
Reference in New Issue