Fix abstract building when additional indexes are built: the raw text must be fetched by get_metadata() from its own index, not the combined one
This commit is contained in:
parent
1cf8327525
commit
b914e1d5b9
@ -685,14 +685,25 @@ int Db::Native::getPageNumberForPosition(const vector<int>& pbreaks, int pos)
|
||||
return int(it - pbreaks.begin() + 1);
|
||||
}
|
||||
|
||||
bool Db::Native::getRawText(Xapian::docid docid, string& rawtext)
|
||||
bool Db::Native::getRawText(Xapian::docid docid_combined, string& rawtext)
|
||||
{
|
||||
if (!m_storetext) {
|
||||
LOGDEB("Db::Native::getRawText: document text not stored in index\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Xapian get_metadata only works on a single index (else of
|
||||
// course, unicity of keys can't be ensured). When using multiple
|
||||
// indexes, we need to open the right one.
|
||||
size_t dbidx = whatDbIdx(docid_combined);
|
||||
Xapian::docid docid = whatDbDocid(docid_combined);
|
||||
string reason;
|
||||
XAPTRY(rawtext = xrdb.get_metadata(rawtextMetaKey(docid)), xrdb, reason);
|
||||
if (dbidx != 0) {
|
||||
Xapian::Database db(m_rcldb->m_extraDbs[dbidx-1]);
|
||||
XAPTRY(rawtext = db.get_metadata(rawtextMetaKey(docid)), db, reason);
|
||||
} else {
|
||||
XAPTRY(rawtext = xrdb.get_metadata(rawtextMetaKey(docid)), xrdb, reason);
|
||||
}
|
||||
if (!reason.empty()) {
|
||||
LOGERR("Rcl::Db::getRawText: could not get value: " << reason << endl);
|
||||
return false;
|
||||
@ -1154,6 +1165,14 @@ size_t Db::Native::whatDbIdx(Xapian::docid id)
|
||||
return (id - 1) % (m_rcldb->m_extraDbs.size() + 1);
|
||||
}
|
||||
|
||||
// Return the docid inside the non-combined index
|
||||
Xapian::docid Db::Native::whatDbDocid(Xapian::docid docid_combined)
|
||||
{
|
||||
if (m_rcldb->m_extraDbs.size() == 0)
|
||||
return docid_combined;
|
||||
return (docid_combined - 1) / (m_rcldb->m_extraDbs.size() + 1) + 1;
|
||||
}
|
||||
|
||||
bool Db::testDbDir(const string &dir, bool *stripped_p)
|
||||
{
|
||||
string aerr;
|
||||
|
||||
@ -136,6 +136,7 @@ class Db::Native {
|
||||
bool fetchtext = false);
|
||||
|
||||
size_t whatDbIdx(Xapian::docid id);
|
||||
Xapian::docid whatDbDocid(Xapian::docid);
|
||||
|
||||
/** Retrieve Xapian::docid, given unique document identifier,
|
||||
* using the posting list for the derived term.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user