diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 283238a..c8e0aee 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -20,7 +20,8 @@ #include #include #include -#include +#include +#include using namespace std; @@ -210,7 +211,8 @@ static int accessHandlerCallback(void *cls, pthread_mutex_lock(&searcherLock); try { - searcher->search(pattern, 30, verboseFlag); + std::string patternString = string(pattern); + searcher->search(patternString, 30, verboseFlag); content = "Kiwix search results

Results


    \n"; while (searcher->getNextResult(urlStr, titleStr, scoreInt)) { sprintf(scoreStr, "%d", scoreInt); @@ -374,17 +376,31 @@ int main(int argc, char **argv) { /* Instanciate the ZIM index (if necessary) */ if (indexPath != "") { + + /* Try with the XapianSearcher */ try { - searcher = new kiwix::Searcher(indexPath); + searcher = new kiwix::XapianSearcher(indexPath); hasSearchIndex = true; } catch (...) { - cerr << "Unable to open the search index '" << zimPath << "'." << endl; - exit(1); + cerr << "Unable to open the search index '" << zimPath << "' with the XapianSearcher." << endl; } + + /* Try with the CluceneSearcher */ + if (!hasSearchIndex) { + try { + searcher = new kiwix::CluceneSearcher(indexPath); + hasSearchIndex = true; + } catch (...) { + cerr << "Unable to open the search index '" << zimPath << "' with the CluceneSearcher." << endl; + exit(1); + } + } + } else { hasSearchIndex = false; } + /* Fork if necessary */ if (daemonFlag) { pid_t pid;