3
0
Fork 0

Merge pull request #18 from kiwix/snippets

Update to the new API of kiwix-lib.
small_fixes
Matthieu Gautier 9 years ago committed by GitHub
commit 856b487007

@ -89,7 +89,8 @@ int main(int argc, char **argv) {
/* Try to prepare the indexing */
try {
searcher = new kiwix::XapianSearcher(indexPath);
/* We will not get the snippets, So we do not need to pass the reader */
searcher = new kiwix::XapianSearcher(indexPath, NULL);
} catch (...) {
cerr << "Unable to search through index '" << indexPath << "'." << endl;
exit(1);
@ -99,11 +100,10 @@ int main(int argc, char **argv) {
if (searcher != NULL) {
string searchString(search);
searcher->search(searchString, 0, 10);
string url;
string title;
unsigned int score;
while (searcher->getNextResult(url, title, score)) {
cout << title << endl;
Result* p_result;
while ( (p_result = searcher->getNextResult()) ) {
cout << p_result->get_title() << endl;
delete p_result;
}
delete searcher;

@ -394,12 +394,14 @@ struct MHD_Response* handle_search(struct MHD_Connection * connection,
/* Get the results */
pthread_mutex_lock(&searcherLock);
pthread_mutex_lock(&readerLock);
try {
searcher->search(patternString, startNumber, endNumber, isVerbose());
content = searcher->getHtml();
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
pthread_mutex_unlock(&readerLock);
pthread_mutex_unlock(&searcherLock);
} else {
content = "<!DOCTYPE html>\n<html><head><meta content=\"text/html;charset=UTF-8\" http-equiv=\"content-type\" /><title>Fulltext search unavailable</title></head><body><h1>Not Found</h1><p>There is no article with the title <b>\"" + kiwix::encodeDiples(patternString) + "\"</b> and the fulltext search engine is not available for this content.</p></body></html>";
@ -858,7 +860,7 @@ int main(int argc, char **argv) {
if (!indexPath.empty()) {
try {
kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath);
kiwix::Searcher *searcher = new kiwix::XapianSearcher(indexPath, reader);
searcher->setProtocolPrefix("/");
searcher->setSearchProtocolPrefix("/search?");
searcher->setContentHumanReadableId(humanReadableId);

Loading…
Cancel
Save