|
|
|
@ -221,7 +221,7 @@ static int accessHandlerCallback(void *cls,
|
|
|
|
if (isVerbose()) {
|
|
|
|
if (isVerbose()) {
|
|
|
|
std::cout << "Searching suggestions for: \"" << term << "\"" << endl;
|
|
|
|
std::cout << "Searching suggestions for: \"" << term << "\"" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Get the suggestions */
|
|
|
|
/* Get the suggestions */
|
|
|
|
content = "[";
|
|
|
|
content = "[";
|
|
|
|
reader->searchSuggestions(term, maxSuggestionCount);
|
|
|
|
reader->searchSuggestions(term, maxSuggestionCount);
|
|
|
|
@ -231,8 +231,7 @@ static int accessHandlerCallback(void *cls,
|
|
|
|
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
|
|
|
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
|
|
|
suggestionCount++;
|
|
|
|
suggestionCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << suggestionCount << std::endl;
|
|
|
|
|
|
|
|
/* Try to get further suggestions with ucFirst(pattern) if maxSuggestionCount is not reached */
|
|
|
|
/* Try to get further suggestions with ucFirst(pattern) if maxSuggestionCount is not reached */
|
|
|
|
if (suggestionCount < 10) {
|
|
|
|
if (suggestionCount < 10) {
|
|
|
|
term = kiwix::ucFirst(term);
|
|
|
|
term = kiwix::ucFirst(term);
|
|
|
|
@ -249,7 +248,7 @@ static int accessHandlerCallback(void *cls,
|
|
|
|
if (suggestionCount < 10) {
|
|
|
|
if (suggestionCount < 10) {
|
|
|
|
term = kiwix::lcFirst(term);
|
|
|
|
term = kiwix::lcFirst(term);
|
|
|
|
reader->searchSuggestions(term, maxSuggestionCount);
|
|
|
|
reader->searchSuggestions(term, maxSuggestionCount);
|
|
|
|
while (reader->getNextSuggestion(suggestion) && suggestionCount < 10)
|
|
|
|
while (reader->getNextSuggestion(suggestion) && suggestionCount < 10) {
|
|
|
|
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
|
|
|
kiwix::stringReplacement(suggestion, "\"", "\\\"");
|
|
|
|
content += (content == "[" ? "" : ",");
|
|
|
|
content += (content == "[" ? "" : ",");
|
|
|
|
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
|
|
|
content += "{\"value\":\"" + suggestion + "\",\"label\":\"" + suggestion + "\"}";
|
|
|
|
|