This commit is contained in:
mhutti1 2016-10-07 16:44:39 +01:00
commit e950ad3a0c
2 changed files with 15 additions and 9 deletions

View File

@ -36,18 +36,16 @@ namespace kiwix {
/* Open Xapian readable database */
void XapianSearcher::openIndex(const string &directoryPath) {
bool indexInZim = false;
try
{
zim::File zimFile = zim::File(directoryPath);
zim::Article xapianArticle = zimFile.getArticle('Z', "/Z/fulltextIndex/xapian");
if (xapianArticle.good())
{
zim::offset_type dbOffset = xapianArticle.getOffset();
int databasefd = open(directoryPath.c_str(), O_RDONLY);
lseek(databasefd, dbOffset, SEEK_SET);
this->readableDatabase = Xapian::Database(databasefd);
}
zim::Article xapianArticle = zimFile.getArticle('Z', "/fulltextIndex/xapian");
if ( ! xapianArticle.good())
throw NoXapianIndexInZim();
zim::offset_type dbOffset = xapianArticle.getOffset();
int databasefd = open(directoryPath.c_str(), O_RDONLY);
lseek(databasefd, dbOffset, SEEK_SET);
this->readableDatabase = Xapian::Database(databasefd);
} catch (zim::ZimFileFormatError)
{
this->readableDatabase = Xapian::Database(directoryPath);

View File

@ -27,6 +27,14 @@ using namespace std;
namespace kiwix {
class NoXapianIndexInZim: public exception
{
virtual const char* what() const throw()
{
return "There is no fulltext index in the zim file";
}
};
class XapianSearcher : public Searcher {
public: