Skip to content

Conversation

@pszklarska
Copy link

(Partially) fixed issue #844 by:

  1. incrementing time of debounce for search filter from 0.3s to 0.5s. The smaller time was causing sending multiple requests before user ended typing and when they showed up, they were already out-of-date. Incrementing time by 0.2s is not visible to the user, so it doesn’t impact UX.
  2. adding sorting results by string similarity - I used java-string-similarity library with a Levenshtein algorithm to implement this. There are some tests write for sorting, so you can check how it works.

However, because of a limited number of results from API, this fix is not 100% correct - there can be better results for user inputs that are on the next pages of this request, so this solution only improves search for what we already get from API.

@commons-app commons-app deleted a comment Sep 5, 2017
@codecov-io
Copy link

codecov-io commented Sep 5, 2017

Codecov Report

Merging #867 into master will increase coverage by 0.21%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #867      +/-   ##
=========================================
+ Coverage    6.91%   7.12%   +0.21%     
=========================================
  Files          95      96       +1     
  Lines        5018    5038      +20     
  Branches      471     473       +2     
=========================================
+ Hits          347     359      +12     
- Misses       4644    4651       +7     
- Partials       27      28       +1
Impacted Files Coverage Δ
...e/nrw/commons/category/CategorizationFragment.java 0% <0%> (ø) ⬆️
.../fr/free/nrw/commons/utils/StringSortingUtils.java 75% <75%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4a89af...0e2d2c1. Read the comment docs.

@commons-app commons-app deleted a comment Sep 5, 2017
@commons-app commons-app deleted a comment Sep 5, 2017
@nicolas-raoul
Copy link
Member

The suggestions are organized in sections, even though the sections are not clearly visible yet (but they will be when #76 is implemented). A section is for suggestions found via GPS, a section is for suggestions from history, a section is for suggestion via Commons search, etc.

So, while sorting could be used within other sections, showing the category with the exact typed name should be done within its own section, so to speak, before all other sections.

@misaochan
Copy link
Member

@pszklarska Thanks for the PR! Admittedly it does somewhat exceed the scope of #844 - I believe that only required a regex to check for the matching string, haha. But I don't mind categories being sorted in order of similarity, personally. Could we please get a screenshot or log of the results for a particular search term?

@nicolas-raoul Do you get GPS, history, etc suggestions when you type in the search filter though? AFAIK how it works currently is that there are two types of category displays. (1) When the text field is empty, it displays GPS, history, etc suggestions. (2) When the text field has input in it, it displays solely results from the string search (alongside any categories that were selected from (1)). As #844 requires a category name to be entered in the search filter, I think it should only affect (2)?

@nicolas-raoul
Copy link
Member

nicolas-raoul commented Sep 6, 2017 via email

@nicolas-raoul
Copy link
Member

nicolas-raoul commented Sep 6, 2017 via email

@pszklarska
Copy link
Author

@nicolas-raoul @misaochan thanks for the comments :) So to sum up, I'd change sorting algorithm to regex (yeah, that might be a little overkill in this situation... I was thinking about sorting because of this comment).
And what about categories? As far as I understand, the results from a search query are categorized, but if you type the exact name of the category it should be shown as a first result?

@misaochan
Copy link
Member

@pszklarska I don't think there is a need to switch to a regex given that you have already done the extra work of implementing sorting. However, I haven't had time to test your PR yet, so it would help us advise you on how to proceed if you could post screenshots or logs of how the category suggestions work in your implementation.

The "categorization" of results mentioned by @nicolas-raoul should not affect this fix, as they only come into play when nothing is typed in the search filter.

@pszklarska
Copy link
Author

Hi guys, sorry for the long delay. Here are screenshots:

For phrase "test" (first one is before implementing sorting, the second one is after)

screen_test_before
screen_test_after

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested, but looks good to me for merging :-)

@pszklarska
Copy link
Author

Cool, thanks! @nicolas-raoul can you merge this?

@nicolas-raoul nicolas-raoul merged commit 9b8d8e9 into commons-app:master Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants