+ better search results

This commit is contained in:
kelson42 2011-03-20 18:47:14 +00:00
parent 5056c59747
commit ef3202dc02
4 changed files with 13 additions and 7 deletions

View File

@ -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,

View File

@ -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);

View File

@ -77,6 +77,7 @@ namespace kiwix {
std::vector<Result>::iterator resultOffset;
std::string resultTemplatePath;
unsigned int estimatedResultCount;
std::string searchPattern;
};
}

View File

@ -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">