From 8878f4e8f33a79eccc5d3f6fb9ca7e3bd54294f7 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Fri, 18 Mar 2011 13:51:41 +0000 Subject: [PATCH] + getEstimatedResultCount() --- src/common/kiwix/searcher.cpp | 11 +++++++++-- src/common/kiwix/searcher.h | 2 ++ src/common/kiwix/xapianSearcher.cpp | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/common/kiwix/searcher.cpp b/src/common/kiwix/searcher.cpp index ca9f62c27..14d2dbc1e 100644 --- a/src/common/kiwix/searcher.cpp +++ b/src/common/kiwix/searcher.cpp @@ -22,12 +22,13 @@ namespace kiwix { /* Constructor */ - Searcher::Searcher() { + Searcher::Searcher() : + estimatedResultCount(0) { } /* Search strings in the database */ void Searcher::search(std::string &search, const unsigned int resultsCount, const bool verbose) { - + this->reset(); if (verbose == true) { @@ -44,8 +45,14 @@ namespace kiwix { void Searcher::reset() { this->results.clear(); this->resultOffset = this->results.begin(); + this->estimatedResultCount = 0; return; } + + /* Return the result count estimation */ + const unsigned int Searcher::getEstimatedResultCount() { + return this->estimatedResultCount; + } /* Get next result */ bool Searcher::getNextResult(string &url, string &title, unsigned int &score) { diff --git a/src/common/kiwix/searcher.h b/src/common/kiwix/searcher.h index 2ea2708f9..20ae77c32 100644 --- a/src/common/kiwix/searcher.h +++ b/src/common/kiwix/searcher.h @@ -61,6 +61,7 @@ namespace kiwix { void search(std::string &search, const unsigned int resultsCount, const bool verbose=false); bool getNextResult(string &url, string &title, unsigned int &score); + const unsigned int getEstimatedResultCount(); void reset(); const string getHtml(); @@ -70,6 +71,7 @@ namespace kiwix { std::vector results; std::vector::iterator resultOffset; + unsigned int estimatedResultCount; }; } diff --git a/src/common/kiwix/xapianSearcher.cpp b/src/common/kiwix/xapianSearcher.cpp index d11e01e7e..8a9079a3d 100644 --- a/src/common/kiwix/xapianSearcher.cpp +++ b/src/common/kiwix/xapianSearcher.cpp @@ -67,9 +67,11 @@ namespace kiwix { std::cout << i.get_percent() << "% "; std::cout << "\t[" << doc.get_data() << "] - " << doc.get_value(0) << std::endl; } - } + /* Update the global resultCount value*/ + this->estimatedResultCount = matches.get_matches_estimated(); + return; } }