add termDocCnt method

This commit is contained in:
Jean-Francois Dockes 2011-10-04 08:04:17 +02:00
parent 3e533298c0
commit 4ced9bee49
2 changed files with 28 additions and 1 deletions

View File

@ -754,6 +754,32 @@ int Db::docCnt()
return res;
}
int Db::termDocCnt(const string& _term)
{
int res = -1;
if (!m_ndb || !m_ndb->m_isopen)
return -1;
string term;
if (!unacmaybefold(_term, term, "UTF-8", true)) {
LOGINFO(("Db::termDocCnt: unac failed for [%s]\n", _term.c_str()));
return 0;
}
if (m_stops.hasStops() && m_stops.isStop(term)) {
LOGDEB1(("Db::termDocCnt [%s] in stop list\n", term.c_str()));
return 0;
}
XAPTRY(res = m_ndb->xdb().get_termfreq(term), m_ndb->xrdb, m_reason);
if (!m_reason.empty()) {
LOGERR(("Db::termDocCnt: got error: %s\n", m_reason.c_str()));
return -1;
}
return res;
}
bool Db::addQueryDb(const string &dir)
{
LOGDEB(("Db::addQueryDb: ndb %p iswritable %d db [%s]\n", m_ndb,

View File

@ -173,7 +173,8 @@ class Db {
/** Return total docs in db */
int docCnt();
/** Return count of docs which have an occurrence of term */
int termDocCnt(const string& term);
/** Add extra database for querying */
bool addQueryDb(const string &dir);
/** Remove extra database. if dir == "", remove all. */