Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for word length in sorting #4325

Closed
ghost opened this issue Sep 8, 2017 · 1 comment
Closed

Account for word length in sorting #4325

ghost opened this issue Sep 8, 2017 · 1 comment
Labels
bug A bug - let's fix this! usability An issue with ease-of-use or design

Comments

@ghost
Copy link

ghost commented Sep 8, 2017

screenshot_2017-09-08_18-16-16

Clearly I'm searching for "huis" (house), it should be the top result. I don't see an issue with the terms/name translations. (Locale: nl)

My idea would be to account for word length while sorting.

@bhousel bhousel added bug A bug - let's fix this! usability An issue with ease-of-use or design labels Sep 8, 2017
@bhousel
Copy link
Member

bhousel commented Sep 10, 2017

I think in this case "house" is sorted below the others because of this "matchScore": 0.5,:

https://github.com/openstreetmap/iD/blame/9750fa4d829e6e3c361b30ff38a6fc79ff7fc502/data/presets/presets/building/house.json#L20

This was added for #2793 - which is basically saying that sometimes a feature can be tagged as a building and something else, and when that happens, we want to make sure to make rank buildings lower than the other things.

The fix for this would probably be in here - maybe ignore that originalScore stuff in the case of an exact match:

var leading_name = _.filter(searchable, function(a) {
return leading(a.name().toLowerCase());
}).sort(function(a, b) {
var i;
i = b.originalScore - a.originalScore;
if (i !== 0) return i;
i = a.name().toLowerCase().indexOf(value) - b.name().toLowerCase().indexOf(value);
if (i !== 0) return i;
return a.name().length - b.name().length;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug - let's fix this! usability An issue with ease-of-use or design
Projects
None yet
Development

No branches or pull requests

1 participant