From 149c840d99a64fc8c6eb999509a8ca3dfd25cf95 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Sat, 25 Aug 2012 15:36:41 +0000 Subject: [PATCH] + move improved suggestion system (check also variations of the prefix) to reader.cpp --- src/server/kiwix-serve.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 426356a..146056e 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -224,37 +224,13 @@ static int accessHandlerCallback(void *cls, /* Get the suggestions */ content = "["; - reader->searchSuggestions(term, maxSuggestionCount); + reader->searchSuggestionsSmart(term, maxSuggestionCount); while (reader->getNextSuggestion(suggestion)) { kiwix::stringReplacement(suggestion, "\"", "\\\""); content += (content == "[" ? "" : ","); content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; suggestionCount++; } - - /* Try to get further suggestions with ucFirst(pattern) if maxSuggestionCount is not reached */ - if (suggestionCount < 10) { - term = kiwix::ucFirst(term); - reader->searchSuggestions(term, maxSuggestionCount); - while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) { - kiwix::stringReplacement(suggestion, "\"", "\\\""); - content += (content == "[" ? "" : ","); - content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; - suggestionCount++; - } - } - - /* Try to get further suggestions with lcFirst(pattern) if maxSuggestionCount is not reached */ - if (suggestionCount < 10) { - term = kiwix::lcFirst(term); - reader->searchSuggestions(term, maxSuggestionCount); - while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) { - kiwix::stringReplacement(suggestion, "\"", "\\\""); - content += (content == "[" ? "" : ","); - content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}"; - suggestionCount++; - } - } content += (suggestionCount == 0 ? "" : ","); content += "{\"value\":\"" + std::string(term) + " \", \"label\":\"containing '" + std::string(term) + "'...\"}]";