Fuzzy result rank should be based on shortest match. Result ranking in fuzzy searching is partially based on the length of matches: shorter matches are considered more relevant than longer ones. When searching for the text 'user', the length component of the match 'user_group' could
(completer)
| 29 | |
| 30 | |
| 31 | def test_ranking_based_on_shortest_match(completer): |
| 32 | """Fuzzy result rank should be based on shortest match. |
| 33 | |
| 34 | Result ranking in fuzzy searching is partially based on the length |
| 35 | of matches: shorter matches are considered more relevant than |
| 36 | longer ones. When searching for the text 'user', the length |
| 37 | component of the match 'user_group' could be either 4 ('user') or |
| 38 | 7 ('user_gr'). |
| 39 | |
| 40 | This test checks that the fuzzy ranking algorithm uses the shorter |
| 41 | match when calculating result rank. |
| 42 | |
| 43 | """ |
| 44 | |
| 45 | text = "user" |
| 46 | collection = ["api_user", "user_group"] |
| 47 | matches = completer.find_matches(text, collection) |
| 48 | |
| 49 | assert matches[1].priority > matches[0].priority |
| 50 | |
| 51 | |
| 52 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected