From 2fc94514f885f421873762c372ee3a9d9f4726ed Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 11 Aug 2016 17:42:51 +0200 Subject: [PATCH] Add support of embedded ft-index in zim for kiwix-serve and kiwix-search. - kiwix-search will try the embedded ft-index if no indexPath is specified in the library.xml or command argument. - kiwix-search also uses xapianSearcher and xapianSearcher needs zimlib, so add zimlib in compilation flag for searcher. - kiwix-serve already depends on zimlib. --- src/server/kiwix-serve.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 04a48db..6e1d8eb 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -602,17 +602,20 @@ int main(int argc, char **argv) { string humanReadableId = currentBook.getHumanReadableIdFromPath(); readers[humanReadableId] = reader; - /* Instanciate the ZIM index (if necessary) */ - if (!indexPath.empty()) { - try { - kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath); - searcher->setProtocolPrefix("/"); - searcher->setSearchProtocolPrefix("/search?"); - searcher->setContentHumanReadableId(humanReadableId); - searchers[humanReadableId] = searcher; - } catch (...) { - cerr << "Unable to open the search index '" << indexPath << "'." << endl; - } + /* Try to instanciate the zim index. + * If there is no specified indexPath, try to open the + * embedded index in the zim. */ + if (indexPath.empty()) { + indexPath = zimPath; + } + try { + kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath); + searcher->setProtocolPrefix("/"); + searcher->setSearchProtocolPrefix("/search?"); + searcher->setContentHumanReadableId(humanReadableId); + searchers[humanReadableId] = searcher; + } catch (...) { + cerr << "Unable to open the search index '" << indexPath << "'." << endl; } } }