mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-24 04:20:56 -04:00
Update to the new API of kiwix-lib.
This commit is contained in:
parent
a3a0127edb
commit
cb20e719ee
@ -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;
|
||||
|
@ -396,12 +396,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>";
|
||||
@ -862,7 +864,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…
x
Reference in New Issue
Block a user