SearchSuggestOracle: Suggest "self" before other users

For query operators that expect a user, matching users are suggested.
The suggestion includes "self" if "self" matches what the user has
typed. Since "self" is used more frequently to complete queries than
actual user names it should appear first in the suggestion list.
Otherwise if "owner:sel" is typed and there are many user names starting
with "sel" selecting "self" from the suggestion list gets annoying as
one always needs to go to the end of the suggestion list.

Change-Id: I49253b7219d6776c997fbb49047d870f48b8bf89
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2017-06-28 08:22:31 +02:00
parent 79afe49b30
commit d782a4f896

View File

@@ -53,7 +53,6 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
if ("self".startsWith(request.getQuery())) {
final ArrayList<SuggestOracle.Suggestion> r =
new ArrayList<>(response.getSuggestions().size() + 1);
r.addAll(response.getSuggestions());
r.add(
new SuggestOracle.Suggestion() {
@Override
@@ -66,6 +65,7 @@ public class SearchSuggestOracle extends HighlightSuggestOracle {
return "self";
}
});
r.addAll(response.getSuggestions());
response.setSuggestions(r);
}
done.onSuggestionsReady(request, response);