diff --git a/src/common/kiwix/searcher.cpp b/src/common/kiwix/searcher.cpp index fa93c69ef..9bb712b50 100644 --- a/src/common/kiwix/searcher.cpp +++ b/src/common/kiwix/searcher.cpp @@ -160,8 +160,13 @@ namespace kiwix { result["title"] = this->resultOffset->title; result["url"] = this->resultOffset->url; result["snippet"] = this->resultOffset->snippet; - result["size"] = this->beautifyInteger(this->resultOffset->size); - result["wordCount"] = this->beautifyInteger(this->resultOffset->wordCount); + + if (this->resultOffset->size >= 0) + result["size"] = this->beautifyInteger(this->resultOffset->size); + + if (this->resultOffset->wordCount >= 0) + result["wordCount"] = this->beautifyInteger(this->resultOffset->wordCount); + resultsCDT.PushBack(result); this->resultOffset++; } diff --git a/src/common/kiwix/xapianSearcher.cpp b/src/common/kiwix/xapianSearcher.cpp index 8d377bb42..d71bf7406 100644 --- a/src/common/kiwix/xapianSearcher.cpp +++ b/src/common/kiwix/xapianSearcher.cpp @@ -60,8 +60,8 @@ namespace kiwix { result.url = doc.get_data(); result.title = doc.get_value(0); result.snippet = doc.get_value(1); - result.size = atoi(doc.get_value(2).c_str()); - result.wordCount = atoi(doc.get_value(3).c_str()); + result.size = (doc.get_value(2).empty() == true ? -1 : atoi(doc.get_value(2).c_str())); + result.wordCount = (doc.get_value(3).empty() == true ? -1 : atoi(doc.get_value(3).c_str())); result.score = i.get_percent(); this->results.push_back(result);