Skip to content

Commit 18a4a99

Browse files
Made the autocompletion query case-insensitive
Autocompletion query is now case & diacritics insensitive. Ignoring diacritics in the query during autocompletion is probably wrong. However, in the current implementation it cannot be easily fixed, since autocompletion works off of the terms recorded in the title index database, and diacritics info is removed during indexing.
1 parent f6a7177 commit 18a4a99

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/suggestion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ TermCollection getTermCompletions(const SuggestionDataBase& db,
346346
} // unnamed namespace
347347

348348
SuggestionSearch::Results SuggestionSearch::getAutocompletionSuggestions(uint32_t maxCount) const {
349-
QueryInfo queryInfo(m_query);
349+
QueryInfo queryInfo(removeAccents(m_query));
350350

351351
SuggestionSearch::Results r;
352352
if ( !queryInfo.wordToComplete().empty() ) {

test/suggestion.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,9 @@ TEST(Suggestion, autocompletionSuggestions) {
778778
}));
779779

780780
EXPECT_COMPLETION_SUGGESTION_RESULTS(archive, "Ki", 10, ({
781-
// FIXME: query case matters
781+
"<b>king</b>",
782+
"<b>king's</b>", // XXX: possesive form
783+
/*"<b>king-fu</b>", */ // missing
782784
}));
783785

784786
EXPECT_COMPLETION_SUGGESTION_RESULTS(archive, "pa", 10, ({
@@ -787,6 +789,12 @@ TEST(Suggestion, autocompletionSuggestions) {
787789
"<b>patient</b>",
788790
}));
789791

792+
EXPECT_COMPLETION_SUGGESTION_RESULTS(archive, "", 10, ({
793+
"<b>panda</b>", // XXX: diacritics in the query are ignored
794+
"<b>patent</b>", // XXX: diacritics in the query are ignored
795+
"<b>patient</b>", // XXX: diacritics in the query are ignored
796+
}));
797+
790798
EXPECT_COMPLETION_SUGGESTION_RESULTS(archive, "1", 10, ({
791799
"<b>15539</b>", // XXX: non word
792800
"<b>1933</b>", // XXX: non word
@@ -798,8 +806,8 @@ TEST(Suggestion, autocompletionSuggestions) {
798806
}));
799807

800808
EXPECT_COMPLETION_SUGGESTION_RESULTS(archive, "Ze", 10, ({
801-
/* "<b>zebra</b>", */ // XXX: missing because of the case of the query
802-
/* "<b>zero</b>", */ // XXX: missing because of the case of the query
809+
"<b>zebras</b>", // XXX: plural form
810+
"<b>zero</b>",
803811
}));
804812

805813
EXPECT_COMPLETION_SUGGESTION_RESULTS(archive, "fo", 10, ({

0 commit comments

Comments
 (0)