Merge lp:~jpakkane/unity-lens-applications/search-fixes into lp:unity-lens-applications

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 329
Merged at revision: 329
Proposed branch: lp:~jpakkane/unity-lens-applications/search-fixes
Merge into: lp:unity-lens-applications
Diff against target: 26 lines (+6/-4)
1 file modified
src/unity-package-search.cc (+6/-4)
To merge this branch: bzr merge lp:~jpakkane/unity-lens-applications/search-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Łukasz Zemczak Approve
Review via email: mp+151720@code.launchpad.net

Commit message

Only use fuzzy matching if Xapian does not find anything.

Description of the change

Only use fuzzy matching if Xapian does not find anything.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

I do think we need at least integration tests for this particular cases, as we got a regression showing it's not enough covered :)

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity-package-search.cc'
2--- src/unity-package-search.cc 2013-02-28 08:21:02 +0000
3+++ src/unity-package-search.cc 2013-03-05 10:38:24 +0000
4@@ -622,18 +622,20 @@
5 UnityPackageSearchType search_type,
6 UnityPackageSort sort)
7 {
8-
9+ UnityPackageSearchResult *xap_result;
10 g_return_val_if_fail (searcher != NULL, NULL);
11 g_return_val_if_fail (search_string != NULL, NULL);
12
13 bool has_category = strstr(search_string, "category:") != NULL;
14 const char *col_query_str = strstr(search_string, "AND");
15- if(has_category || !col_query_str) {
16- return xapian_search(searcher, search_string, max_hits, search_type, sort);
17- } else {
18+ xap_result = xapian_search(searcher, search_string, max_hits, search_type, sort);
19+ // If Xapian does not find anything, try fuzzy matching.
20+ if(g_slist_length(xap_result->results) == 0 && (!has_category && col_query_str)) {
21+ g_slice_free(UnityPackageSearchResult, xap_result);
22 col_query_str += 3;
23 return libcolumbus_search(searcher, col_query_str);
24 }
25+ return xap_result;
26 }
27
28

Subscribers

People subscribed via source and target branches