query: extract the collapse count from xapian + small cleanups
This commit is contained in:
parent
9b738ebb61
commit
34511918d9
@ -754,7 +754,7 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
||||
}
|
||||
if (curPreview == 0) {
|
||||
HiliteData hdata;
|
||||
reslist->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
||||
m_source->getTerms(hdata.terms, hdata.groups, hdata.gslks);
|
||||
curPreview = new Preview(reslist->listId(), hdata);
|
||||
|
||||
if (curPreview == 0) {
|
||||
@ -1217,12 +1217,16 @@ void RclMain::startManual(const string& index)
|
||||
// significant terms, and add them to the simple search entry.
|
||||
void RclMain::docExpand(Rcl::Doc doc)
|
||||
{
|
||||
LOGDEB(("RclMain::docExpand()\n"));
|
||||
if (!rcldb)
|
||||
return;
|
||||
list<string> terms;
|
||||
terms = reslist->expand(doc);
|
||||
if (terms.empty())
|
||||
|
||||
terms = m_source->expand(doc);
|
||||
if (terms.empty()) {
|
||||
LOGDEB(("RclMain::docExpand: no terms\n"));
|
||||
return;
|
||||
}
|
||||
// Do we keep the original query. I think we'd better not.
|
||||
// rcldb->expand is set to keep the original query terms instead.
|
||||
QString text;// = sSearch->queryText->currentText();
|
||||
|
||||
@ -336,19 +336,6 @@ void ResList::languageChange()
|
||||
setWindowTitle(tr("Result list"));
|
||||
}
|
||||
|
||||
bool ResList::getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups, vector<int>& gslks)
|
||||
{
|
||||
return m_source->getTerms(terms, groups, gslks);
|
||||
}
|
||||
|
||||
list<string> ResList::expand(Rcl::Doc& doc)
|
||||
{
|
||||
if (m_source.isNull())
|
||||
return list<string>();
|
||||
return m_source->expand(doc);
|
||||
}
|
||||
|
||||
// Get document number from paragraph number
|
||||
int ResList::docnumfromparnum(int par)
|
||||
{
|
||||
|
||||
@ -42,15 +42,13 @@ class ResList : public QTextBrowser
|
||||
ResList(QWidget* parent = 0, const char* name = 0);
|
||||
virtual ~ResList();
|
||||
|
||||
// Return document for given docnum. We act as an intermediary to
|
||||
// the docseq here. This has also the side-effect of making the
|
||||
// entry current (visible and highlighted), and only works if the
|
||||
// num is inside the current page or its immediate neighbours.
|
||||
// Return document for given docnum. We mostly act as an
|
||||
// intermediary to the docseq here, but this has also the
|
||||
// side-effect of making the entry current (visible and
|
||||
// highlighted), and only works if the num is inside the current
|
||||
// page or its immediate neighbours.
|
||||
bool getDoc(int docnum, Rcl::Doc &);
|
||||
bool displayingHistory();
|
||||
bool getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups, vector<int>& gslks);
|
||||
list<string> expand(Rcl::Doc& doc);
|
||||
int listId() const {return m_listId;}
|
||||
|
||||
public slots:
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"));
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user