After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680163 - Use a ranking algorithm for displaying search results
Use a ranking algorithm for displaying search results
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-07-18 12:12 UTC by William Jon McCann
Modified: 2012-08-01 11:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add a way to rank search results (32.53 KB, patch)
2012-07-19 20:19 UTC, William Jon McCann
none Details | Review
Add a way to rank search results (33.66 KB, patch)
2012-07-21 05:33 UTC, William Jon McCann
reviewed Details | Review
Add a way to rank search results (33.86 KB, patch)
2012-08-01 11:13 UTC, William Jon McCann
committed Details | Review

Description William Jon McCann 2012-07-18 12:12:58 UTC
I think it might be nice to have a ranking algorithm that can be used to determine the order of search results displayed. Currently, we sort the result by name by default I think.

It may be nice to be able to sort the results by:
 * Relevance
 * Use (frecency?)
 * Name

The rank should account for at least:
 * Proximity to current location
 * Time since last use
 * Time since last modification
 * Text match score

One possibility would be to add a column to the search directory view for something like "Relevance" etc. The problem is that the value used in this column would be unintelligible most of the time.
Comment 1 William Jon McCann 2012-07-19 20:19:52 UTC
Created attachment 219274 [details] [review]
Add a way to rank search results

We give each search hit a relevance score computed from the sum
of proximity, recent, and text match bonuses.

The search results are ordered by this value by default.
Comment 2 William Jon McCann 2012-07-21 05:33:59 UTC
Created attachment 219368 [details] [review]
Add a way to rank search results

We give each search hit a relevance score computed from the sum
of proximity, recent, and text match bonuses.

The search results are ordered by this value by default.
Comment 3 Cosimo Cecchi 2012-08-01 10:56:28 UTC
Review of attachment 219368 [details] [review]:

Looks mostly good, just some comments below.

::: libnautilus-private/nautilus-search-engine-simple.c
@@ +275,3 @@
+			GDateTime *dt;
+
+			hit = nautilus_search_hit_new (g_file_get_uri (child));

This leaks the uri

::: libnautilus-private/nautilus-search-hit.c
@@ +51,3 @@
+void
+nautilus_search_hit_score (NautilusSearchHit *hit,
+			   NautilusQuery     *query)

The API of this is a little weird, we could just return the relevance score from the function, instead of having a separate function (or keep both, but it looks to me that returning it from here would be enough for the use we make of it in NautilusSearchDirectory).

@@ +111,3 @@
+	else {
+		recent_bonus = 100.0;
+	}

The coding style for these if branches here is inconsistent...in Nautilus we always put curly braces around conditions, even if the condition is one line.

@@ +243,3 @@
+	NautilusSearchHit *hit = NAUTILUS_SEARCH_HIT (object);
+
+	g_free (hit->details->uri);

Need to g_date_unref modification_time and access_time here.
Comment 4 William Jon McCann 2012-08-01 11:13:35 UTC
Created attachment 220046 [details] [review]
Add a way to rank search results

We give each search hit a relevance score computed from the sum
of proximity, recent, and text match bonuses.

The search results are ordered by this value by default.
Comment 5 William Jon McCann 2012-08-01 11:20:14 UTC
Attachment 220046 [details] pushed as 2156d24 - Add a way to rank search results