Merge pull request #64 from kiwix/fix_protocol

Correctly set ProtocolPrefix and SearchProtocolPrefix for searcher.
This commit is contained in:
Matthieu Gautier 2017-08-11 00:44:28 -04:00 committed by GitHub
commit f44722fbbc
2 changed files with 6 additions and 4 deletions

View File

@ -86,10 +86,11 @@ int main(int argc, char** argv)
} }
if (reader) { if (reader) {
searcher = new kiwix::Searcher("", reader); searcher = new kiwix::Searcher();
searcher->add_reader(reader, "");
} else { } else {
try { try {
searcher = new kiwix::Searcher(zimPath, NULL); searcher = new kiwix::Searcher(zimPath, NULL, "");
} catch (...) { } catch (...) {
cerr << "Unable to search through zim '" << zimPath << "'." << endl; cerr << "Unable to search through zim '" << zimPath << "'." << endl;
exit(1); exit(1);

View File

@ -942,15 +942,16 @@ int main(int argc, char** argv)
if ( reader->hasFulltextIndex()) { if ( reader->hasFulltextIndex()) {
kiwix::Searcher* searcher = new kiwix::Searcher(); kiwix::Searcher* searcher = new kiwix::Searcher();
searcher->setProtocolPrefix("/");
searcher->setSearchProtocolPrefix("/search?");
searcher->add_reader(reader, humanReadableId); searcher->add_reader(reader, humanReadableId);
globalSearcher->add_reader(reader, humanReadableId); globalSearcher->add_reader(reader, humanReadableId);
searchers[humanReadableId] = searcher; searchers[humanReadableId] = searcher;
} else if ( !indexPath.empty() ) { } else if ( !indexPath.empty() ) {
try { try {
kiwix::Searcher* searcher = new kiwix::Searcher(indexPath, reader); kiwix::Searcher* searcher = new kiwix::Searcher(indexPath, reader, humanReadableId);
searcher->setProtocolPrefix("/"); searcher->setProtocolPrefix("/");
searcher->setSearchProtocolPrefix("/search?"); searcher->setSearchProtocolPrefix("/search?");
searcher->setContentHumanReadableId(humanReadableId);
searchers[humanReadableId] = searcher; searchers[humanReadableId] = searcher;
} catch (...) { } catch (...) {
cerr << "Unable to open the search index '" << indexPath << "'." cerr << "Unable to open the search index '" << indexPath << "'."