add relevancyrating to the metadata when querying
This commit is contained in:
parent
4876574e3e
commit
aeda846cdd
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.141 2008-08-30 12:21:41 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.142 2008-09-05 10:34:17 dockes Exp $ (C) 2004 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -130,7 +130,8 @@ bool Db::Native::subDocs(const string &udi, vector<Xapian::docid>& docids)
|
||||
}
|
||||
|
||||
// Turn data record from db into document fields
|
||||
bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc)
|
||||
bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||
Doc &doc, int percent)
|
||||
{
|
||||
LOGDEB1(("Db::dbDataToRclDoc: data: %s\n", data.c_str()));
|
||||
ConfSimple parms(&data);
|
||||
@ -152,6 +153,9 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc
|
||||
doc.meta["abstract"] = doc.meta["abstract"].substr(rclSyntAbs.length());
|
||||
doc.syntabs = true;
|
||||
}
|
||||
char buf[20];
|
||||
sprintf(buf,"%.2f", float(percent) / 100.0);
|
||||
doc.meta["relevancyrating"] = buf;
|
||||
parms.get(string("ipath"), doc.ipath);
|
||||
parms.get(string("fbytes"), doc.fbytes);
|
||||
parms.get(string("dbytes"), doc.dbytes);
|
||||
@ -1556,7 +1560,7 @@ bool Db::getDoc(const string &udi, Doc &doc, int *pc)
|
||||
Xapian::Document xdoc = m_ndb->db.get_document(*docid);
|
||||
string data = xdoc.get_data();
|
||||
list<string> terms;
|
||||
return m_ndb->dbDataToRclDoc(*docid, data, doc);
|
||||
return m_ndb->dbDataToRclDoc(*docid, data, doc, 100);
|
||||
} XCATCHERROR(ermsg);
|
||||
if (!ermsg.empty()) {
|
||||
LOGERR(("Db::getDoc: %s\n", ermsg.c_str()));
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include "xapian.h"
|
||||
|
||||
namespace Rcl {
|
||||
/* @(#$Id: rcldb_p.h,v 1.3 2008-07-29 06:25:29 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
/* @(#$Id: rcldb_p.h,v 1.4 2008-09-05 10:34:17 dockes Exp $ (C) 2007 J.F.Dockes */
|
||||
|
||||
// Generic Xapian exception catching code. We do this quite often,
|
||||
// and I have no idea how to do this except for a macro
|
||||
@ -49,7 +49,8 @@ class Db::Native {
|
||||
|
||||
string makeAbstract(Xapian::docid id, Query *query);
|
||||
|
||||
bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
|
||||
bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc,
|
||||
int percent);
|
||||
|
||||
/** Compute list of subdocuments for a given udi. We look for documents
|
||||
* indexed by a parent term matching the udi, the posting list for the
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.3 2008-07-01 11:51:51 dockes Exp $ (C) 2008 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.4 2008-09-05 10:34:17 dockes Exp $ (C) 2008 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
@ -303,12 +303,13 @@ bool Query::getDoc(int exti, Doc &doc, int *percent)
|
||||
|
||||
Xapian::Document xdoc = m_nq->mset[xapi-first].get_document();
|
||||
Xapian::docid docid = *(m_nq->mset[xapi-first]);
|
||||
int pc = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
|
||||
if (percent)
|
||||
*percent = m_nq->mset.convert_to_percent(m_nq->mset[xapi-first]);
|
||||
*percent = pc;
|
||||
|
||||
// Parse xapian document's data and populate doc fields
|
||||
string data = xdoc.get_data();
|
||||
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc);
|
||||
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc, pc);
|
||||
}
|
||||
|
||||
list<string> Query::expand(const Doc &doc)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user