From f12a731939983c97e40765db7ca89c7396454648 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sun, 28 May 2017 23:11:02 +0200 Subject: [PATCH] Adapt to new kiwix-lib search API. --- src/searcher/kiwix-search.cpp | 16 ++++++++++++---- src/server/kiwix-serve.cpp | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/searcher/kiwix-search.cpp b/src/searcher/kiwix-search.cpp index bd53c9c..c3f14c7 100644 --- a/src/searcher/kiwix-search.cpp +++ b/src/searcher/kiwix-search.cpp @@ -80,12 +80,20 @@ int main(int argc, char **argv) { /* Try to prepare the indexing */ try { - /* We will not get the snippets, So we do not need to pass the reader */ reader = new kiwix::Reader(zimPath); - searcher = new kiwix::Searcher(reader); } catch (...) { - cerr << "Unable to search through zim '" << zimPath << "'." << endl; - exit(1); + /* Cannot open the zimPath, maybe it is a plain old xapian database directory */ + } + + if ( reader ) { + searcher = new kiwix::Searcher("", reader); + } else { + try { + searcher = new kiwix::Searcher(zimPath, NULL); + } catch (...) { + cerr << "Unable to search through zim '" << zimPath << "'." << endl; + exit(1); + } } /* Start the indexing */ diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 7738b12..a0d0f4a 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -856,7 +856,7 @@ int main(int argc, char **argv) { if (!indexPath.empty()) { try { - kiwix::Searcher *searcher = new kiwix::Searcher(reader); + kiwix::Searcher *searcher = new kiwix::Searcher(indexPath, reader); searcher->setProtocolPrefix("/"); searcher->setSearchProtocolPrefix("/search?"); searcher->setContentHumanReadableId(humanReadableId);