query: extract the collapse count from xapian + small cleanups

This commit is contained in:
Jean-Francois Dockes
2011-01-17 11:25:05 +01:00
parent 9b738ebb61
commit 34511918d9
7 changed files with 27 additions and 31 deletions
+1
View File
@@ -35,6 +35,7 @@ namespace Rcl {
const string Doc::keysz("size");
const string Doc::keysig("sig");
const string Doc::keyrr("relevancyrating");
const string Doc::keycc("collapsecount");
const string Doc::keyabs("abstract");
const string Doc::keyau("author");
const string Doc::keytt("title");
+1
View File
@@ -155,6 +155,7 @@ class Doc {
static const string keysz; // dbytes if set else fbytes
static const string keysig; // sig
static const string keyrr; // relevancy rating
static const string keycc; // Collapse count
static const string keyabs; // abstract
static const string keyau; // author
static const string keytt; // title
+8 -2
View File
@@ -321,12 +321,14 @@ bool Query::getDoc(int xapi, Doc &doc)
Xapian::Document xdoc;
Xapian::docid docid = 0;
int pc = 0;
int collapsecount = 0;
string data;
string udi;
m_reason.erase();
for (int xaptries=0; xaptries < 2; xaptries++) {
try {
xdoc = m_nq->xmset[xapi-first].get_document();
collapsecount = m_nq->xmset[xapi-first].get_collapse_count();
docid = *(m_nq->xmset[xapi-first]);
pc = m_nq->xmset.convert_to_percent(m_nq->xmset[xapi-first]);
data = xdoc.get_data();
@@ -339,8 +341,8 @@ bool Query::getDoc(int xapi, Doc &doc)
if (!udi.empty())
udi = udi.substr(1);
}
LOGDEB2(("Query::getDoc: %d ms to get udi [%s]\n", chron.millis(),
udi.c_str()));
LOGDEB2(("Query::getDoc: %d ms for udi [%s], collapse count %d\n",
chron.millis(), udi.c_str(), collapsecount));
break;
} catch (Xapian::DatabaseModifiedError &error) {
// retry or end of loop
@@ -355,6 +357,9 @@ bool Query::getDoc(int xapi, Doc &doc)
return false;
}
doc.meta[Rcl::Doc::keyudi] = udi;
char scc[30];
sprintf(scc, "%d", collapsecount);
doc.meta[Rcl::Doc::keycc] = scc;
// Parse xapian document's data and populate doc fields
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc, pc);
@@ -362,6 +367,7 @@ bool Query::getDoc(int xapi, Doc &doc)
list<string> Query::expand(const Doc &doc)
{
LOGDEB(("Rcl::Query::expand()\n"));
list<string> res;
if (ISNULL(m_nq) || !m_nq->xenquire) {
LOGERR(("Query::expand: no query opened\n"));
+5 -6
View File
@@ -869,13 +869,12 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p,
(m_parentSearch && !m_parentSearch->haveWildCards()) ||
(m_parentSearch == 0 && !m_haveWildCards);
// We produce a single phrase out of the user entry (there should be
// no dquotes in there), then use stringToXapianQueries() to
// lowercase and simplify the phrase terms etc. This will result
// into a single (complex) Xapian::Query.
// We produce a single phrase out of the user entry then use
// stringToXapianQueries() to lowercase and simplify the phrase
// terms etc. This will result into a single (complex)
// Xapian::Query.
if (m_text.find_first_of("\"") != string::npos) {
LOGDEB(("Double quotes inside phrase/near field\n"));
return false;
m_text = neutchars(m_text, "\"");
}
string s = string("\"") + m_text + string("\"");
bool useNear = (m_tp == SCLT_NEAR);