+ update to kiwix-serve code to be able to deal with clucene backends

pull/9/head
kelson42 16 years ago
parent cf0a433b67
commit 5f97db25e0

@ -20,7 +20,8 @@
#include <regex.h> #include <regex.h>
#include <zlib.h> #include <zlib.h>
#include <kiwix/reader.h> #include <kiwix/reader.h>
#include <kiwix/searcher.h> #include <kiwix/xapianSearcher.h>
#include <kiwix/cluceneSearcher.h>
using namespace std; using namespace std;
@ -210,7 +211,8 @@ static int accessHandlerCallback(void *cls,
pthread_mutex_lock(&searcherLock); pthread_mutex_lock(&searcherLock);
try { try {
searcher->search(pattern, 30, verboseFlag); std::string patternString = string(pattern);
searcher->search(patternString, 30, verboseFlag);
content = "<html><head><title>Kiwix search results</title></head><body><h1>Results</h1><hr/><ol>\n"; content = "<html><head><title>Kiwix search results</title></head><body><h1>Results</h1><hr/><ol>\n";
while (searcher->getNextResult(urlStr, titleStr, scoreInt)) { while (searcher->getNextResult(urlStr, titleStr, scoreInt)) {
sprintf(scoreStr, "%d", scoreInt); sprintf(scoreStr, "%d", scoreInt);
@ -374,17 +376,31 @@ int main(int argc, char **argv) {
/* Instanciate the ZIM index (if necessary) */ /* Instanciate the ZIM index (if necessary) */
if (indexPath != "") { if (indexPath != "") {
/* Try with the XapianSearcher */
try { try {
searcher = new kiwix::Searcher(indexPath); searcher = new kiwix::XapianSearcher(indexPath);
hasSearchIndex = true; hasSearchIndex = true;
} catch (...) { } catch (...) {
cerr << "Unable to open the search index '" << zimPath << "'." << endl; 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); exit(1);
} }
}
} else { } else {
hasSearchIndex = false; hasSearchIndex = false;
} }
/* Fork if necessary */ /* Fork if necessary */
if (daemonFlag) { if (daemonFlag) {
pid_t pid; pid_t pid;

Loading…
Cancel
Save