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 */
|
||||
stringstream st;
|
||||
st << countWords(this->htmlParser.dump);
|
||||
const std::string wordCountString = st.str();
|
||||
stringstream countWordStringStream;
|
||||
countWordStringStream << countWords(this->htmlParser.dump);
|
||||
const std::string wordCountString = countWordStringStream.str();
|
||||
|
||||
/* snippet */
|
||||
const std::string snippet = std::string(this->htmlParser.dump, 0, 300);
|
||||
|
||||
/* size */
|
||||
st << content.size();
|
||||
const std::string size = st.str();
|
||||
stringstream sizeStringStream;
|
||||
sizeStringStream << content.size() / 1024;
|
||||
const std::string size = sizeStringStream.str();
|
||||
|
||||
this->indexNextArticle(url,
|
||||
accentedTitle,
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace kiwix {
|
|||
/* Constructor */
|
||||
Searcher::Searcher() :
|
||||
estimatedResultCount(0),
|
||||
resultTemplatePath("") {
|
||||
resultTemplatePath(""),
|
||||
searchPattern("") {
|
||||
}
|
||||
|
||||
/* Search strings in the database */
|
||||
|
@ -36,6 +37,7 @@ namespace kiwix {
|
|||
cout << "Performing query `" << search << "'" << endl;
|
||||
}
|
||||
|
||||
this->searchPattern = search;
|
||||
searchInIndex(removeAccents(search), resultsCount, verbose);
|
||||
this->resultOffset = this->results.begin();
|
||||
|
||||
|
@ -47,6 +49,7 @@ namespace kiwix {
|
|||
this->results.clear();
|
||||
this->resultOffset = this->results.begin();
|
||||
this->estimatedResultCount = 0;
|
||||
this->searchPattern = "";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -145,6 +148,7 @@ namespace kiwix {
|
|||
|
||||
oData["results"] = resultsCDT;
|
||||
oData["count"] = this->estimatedResultCount;
|
||||
oData["searchPattern"] = this->searchPattern;
|
||||
|
||||
STLW::string sResult;
|
||||
StringOutputCollector oDataCollector(sResult);
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace kiwix {
|
|||
std::vector<Result>::iterator resultOffset;
|
||||
std::string resultTemplatePath;
|
||||
unsigned int estimatedResultCount;
|
||||
std::string searchPattern;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<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 class="results">
|
||||
|
|
Loading…
Reference in New Issue