catch Xapian exception caused by bad stemming language. Check stemdb creation status and have recollindex exit in error if it failed
This commit is contained in:
parent
c0892d2327
commit
589c59f6a4
2 changed files with 40 additions and 36 deletions
|
@ -140,14 +140,17 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
|
||||||
|
|
||||||
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_CLOSING, string()))
|
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_CLOSING, string()))
|
||||||
return false;
|
return false;
|
||||||
createStemmingDatabases();
|
bool ret = true;
|
||||||
|
if (!createStemmingDatabases()) {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_CLOSING, string()))
|
if (m_updater && !m_updater->update(DbIxStatus::DBIXS_CLOSING, string()))
|
||||||
return false;
|
return false;
|
||||||
createAspellDict();
|
ret = ret && createAspellDict();
|
||||||
clearMimeHandlerCache();
|
clearMimeHandlerCache();
|
||||||
if (m_updater)
|
if (m_updater)
|
||||||
m_updater->update(DbIxStatus::DBIXS_DONE, string());
|
m_updater->update(DbIxStatus::DBIXS_DONE, string());
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
|
bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
|
||||||
|
@ -276,6 +279,7 @@ bool ConfIndexer::purgeFiles(std::list<string> &files, int flag)
|
||||||
bool ConfIndexer::createStemmingDatabases()
|
bool ConfIndexer::createStemmingDatabases()
|
||||||
{
|
{
|
||||||
string slangs;
|
string slangs;
|
||||||
|
bool ret = true;
|
||||||
if (m_config->getConfParam("indexstemminglanguages", slangs)) {
|
if (m_config->getConfParam("indexstemminglanguages", slangs)) {
|
||||||
if (!m_db.open(Rcl::Db::DbUpd)) {
|
if (!m_db.open(Rcl::Db::DbUpd)) {
|
||||||
LOGERR("ConfIndexer::createStemmingDb: could not open db\n" );
|
LOGERR("ConfIndexer::createStemmingDb: could not open db\n" );
|
||||||
|
@ -292,10 +296,10 @@ bool ConfIndexer::createStemmingDatabases()
|
||||||
if (find(langs.begin(), langs.end(), *it) == langs.end())
|
if (find(langs.begin(), langs.end(), *it) == langs.end())
|
||||||
m_db.deleteStemDb(*it);
|
m_db.deleteStemDb(*it);
|
||||||
}
|
}
|
||||||
m_db.createStemDbs(langs);
|
ret = ret && m_db.createStemDbs(langs);
|
||||||
}
|
}
|
||||||
m_db.close();
|
m_db.close();
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfIndexer::createStemDb(const string &lang)
|
bool ConfIndexer::createStemDb(const string &lang)
|
||||||
|
|
|
@ -53,40 +53,40 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stem dbs
|
|
||||||
vector<XapWritableComputableSynFamMember> stemdbs;
|
|
||||||
// Note: tried to make this to work with stack-allocated objects, couldn't.
|
|
||||||
// Looks like a bug in copy constructors somewhere, can't guess where
|
|
||||||
vector<std::shared_ptr<SynTermTransStem> > stemmers;
|
|
||||||
for (unsigned int i = 0; i < langs.size(); i++) {
|
|
||||||
stemmers.push_back(std::shared_ptr<SynTermTransStem>
|
|
||||||
(new SynTermTransStem(langs[i])));
|
|
||||||
stemdbs.push_back(
|
|
||||||
XapWritableComputableSynFamMember(wdb, synFamStem, langs[i],
|
|
||||||
stemmers.back().get()));
|
|
||||||
stemdbs.back().recreate();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unaccented stem dbs
|
|
||||||
vector<XapWritableComputableSynFamMember> unacstemdbs;
|
|
||||||
// We can reuse the same stemmer pointers, the objects are stateless.
|
|
||||||
if (!o_index_stripchars) {
|
|
||||||
for (unsigned int i = 0; i < langs.size(); i++) {
|
|
||||||
unacstemdbs.push_back(
|
|
||||||
XapWritableComputableSynFamMember(wdb, synFamStemUnac, langs[i],
|
|
||||||
stemmers.back().get()));
|
|
||||||
unacstemdbs.back().recreate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SynTermTransUnac transunac(UNACOP_UNACFOLD);
|
|
||||||
XapWritableComputableSynFamMember
|
|
||||||
diacasedb(wdb, synFamDiCa, "all", &transunac);
|
|
||||||
if (!o_index_stripchars)
|
|
||||||
diacasedb.recreate();
|
|
||||||
|
|
||||||
// Walk the list of all terms, and stem/unac each.
|
// Walk the list of all terms, and stem/unac each.
|
||||||
string ermsg;
|
string ermsg;
|
||||||
try {
|
try {
|
||||||
|
// Stem dbs
|
||||||
|
vector<XapWritableComputableSynFamMember> stemdbs;
|
||||||
|
// Note: tried to make this to work with stack-allocated objects, couldn't.
|
||||||
|
// Looks like a bug in copy constructors somewhere, can't guess where
|
||||||
|
vector<std::shared_ptr<SynTermTransStem> > stemmers;
|
||||||
|
for (unsigned int i = 0; i < langs.size(); i++) {
|
||||||
|
stemmers.push_back(std::shared_ptr<SynTermTransStem>
|
||||||
|
(new SynTermTransStem(langs[i])));
|
||||||
|
stemdbs.push_back(
|
||||||
|
XapWritableComputableSynFamMember(wdb, synFamStem, langs[i],
|
||||||
|
stemmers.back().get()));
|
||||||
|
stemdbs.back().recreate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unaccented stem dbs
|
||||||
|
vector<XapWritableComputableSynFamMember> unacstemdbs;
|
||||||
|
// We can reuse the same stemmer pointers, the objects are stateless.
|
||||||
|
if (!o_index_stripchars) {
|
||||||
|
for (unsigned int i = 0; i < langs.size(); i++) {
|
||||||
|
unacstemdbs.push_back(
|
||||||
|
XapWritableComputableSynFamMember(wdb, synFamStemUnac, langs[i],
|
||||||
|
stemmers.back().get()));
|
||||||
|
unacstemdbs.back().recreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SynTermTransUnac transunac(UNACOP_UNACFOLD);
|
||||||
|
XapWritableComputableSynFamMember
|
||||||
|
diacasedb(wdb, synFamDiCa, "all", &transunac);
|
||||||
|
if (!o_index_stripchars)
|
||||||
|
diacasedb.recreate();
|
||||||
|
|
||||||
Xapian::TermIterator it = wdb.allterms_begin();
|
Xapian::TermIterator it = wdb.allterms_begin();
|
||||||
// We'd want to skip to the first non-prefixed term, but this is a bit
|
// We'd want to skip to the first non-prefixed term, but this is a bit
|
||||||
// complicated, so we just jump over most of the prefixed term and then
|
// complicated, so we just jump over most of the prefixed term and then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue