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 729027 - Prioritize names over descriptions in search
Prioritize names over descriptions in search
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Search
3.12.x
Other Linux
: Normal normal
: ---
Assigned To: Cosimo Cecchi
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-26 17:02 UTC by Alex Hultman
Modified: 2014-05-16 10:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bad hit (213.67 KB, image/jpeg)
2014-04-26 17:02 UTC, Alex Hultman
  Details
shell: Keep the filter terms cached (2.00 KB, patch)
2014-04-26 21:26 UTC, Rui Matos
committed Details | Review
shell: Make search results sorting smarter (9.87 KB, patch)
2014-04-26 21:26 UTC, Rui Matos
committed Details | Review
display: Add "Monitor" to keywords (1.14 KB, patch)
2014-05-15 18:34 UTC, Rui Matos
committed Details | Review
search-provider: Use panel IDs as results instead of tree model paths (6.98 KB, patch)
2014-05-15 18:35 UTC, Rui Matos
committed Details | Review

Description Alex Hultman 2014-04-26 17:02:42 UTC
Created attachment 275220 [details]
Bad hit

Searching for "Displays" brings up "Color". That's wrong. Prioritize names over description.
Comment 1 Rui Matos 2014-04-26 21:26:40 UTC
Created attachment 275237 [details] [review]
shell: Keep the filter terms cached

This avoids calling g_strsplit() for every model item when filtering.
Comment 2 Rui Matos 2014-04-26 21:26:47 UTC
Created attachment 275238 [details] [review]
shell: Make search results sorting smarter

Instead of just sorting by the name the sort order will now be:

1. Panels whose name match a search term
2. Panels whose keywords match the most search terms
3. Panels whose description match the most search terms
4. The remaining panels by name
Comment 3 Alex Hultman 2014-04-26 22:07:16 UTC
If I search for "disp" - will it list "Displays" as the first hit? Currently I get "Color" when i search for "disp". I mean - will this work for partial names?
Comment 4 Jasper St. Pierre (not reading bugmail) 2014-04-26 22:11:33 UTC
(In reply to comment #1)
> Created an attachment (id=275237) [details] [review]
> shell: Keep the filter terms cached
> 
> This avoids calling g_strsplit() for every model item when filtering.

Might be better to use g_str_match_string / g_str_tokenize_and_fold now?
Comment 5 Bastien Nocera 2014-04-29 13:11:21 UTC
Review of attachment 275237 [details] [review]:

Is this really needed? What impact does it have in terms of performance?
Comment 6 Bastien Nocera 2014-04-29 13:13:45 UTC
Review of attachment 275238 [details] [review]:

That looks fine.

::: shell/cc-shell-model.c
@@ +110,3 @@
+    for (j = 0; keywords[j]; ++j)
+      if (strstr (keywords[j], terms[i]))
+        c += 1;

I prefer c++;
Comment 7 Rui Matos 2014-05-15 11:57:46 UTC
(In reply to comment #5)
> Review of attachment 275237 [details] [review]:
> 
> Is this really needed? What impact does it have in terms of performance?

Didn't measure but I'd be surprised if has any impact given the number of panels.

I just did this because we need the split terms on search_entry_changed_cb to feed into the shell model for sorting in the following patch. And since we now have the terms at that point it seemed wasteful to repeat that work in the filter func.
Comment 8 Rui Matos 2014-05-15 18:34:26 UTC
Created attachment 276619 [details] [review]
display: Add "Monitor" to keywords

It's a likely word that might be used when looking for this panel and,
with the new search results ordering, the power panel is coming up
ahead due to it preferring keyword matches when they exist.
Comment 9 Rui Matos 2014-05-15 18:35:15 UTC
Created attachment 276620 [details] [review]
search-provider: Use panel IDs as results instead of tree model paths

Since we now re-sort the model according to the search terms, we can't
use tree model paths as results since they're not stable. Instead
we'll use panel IDs and keep a map of IDs to GtkTreeIters to retrieve
the result metas from the model.
--

I was testing this a bit more and noticed that something wasn't
right. We need something like this to make results work properly now.
Comment 10 Bastien Nocera 2014-05-16 08:26:42 UTC
Review of attachment 276619 [details] [review]:

Looks good
Comment 11 Bastien Nocera 2014-05-16 08:28:32 UTC
Review of attachment 276620 [details] [review]:

GtkTreeIters aren't "stable" either. You're thinking of GtkTreeRowReferences.

Is there any reason not to search the treeview for it instead? The performance hit would be small, as the number of items is limited.
Comment 12 Rui Matos 2014-05-16 09:27:30 UTC
(In reply to comment #11)
> Review of attachment 276620 [details] [review]:
> 
> GtkTreeIters aren't "stable" either. You're thinking of GtkTreeRowReferences.

They aren't generally. But in the specific case of a GtkListStore the documentation says:

"The GtkListStore sets the GTK_TREE_MODEL_ITERS_PERSIST flag, which means that GtkTreeIters can be cached while the row exists. Thus, if access to a particular row is needed often and your code is expected to run on older versions of GTK+, it is worth keeping the iter around."

> Is there any reason not to search the treeview for it instead? The performance
> hit would be small, as the number of items is limited.

True. But given the above and the fact that the code has been written already I see little value in doing that.
Comment 13 Bastien Nocera 2014-05-16 09:32:30 UTC
Then please mention it in the commit log and in the code, because it's certainly not clear when one's used to GtkTreeView.
Comment 14 Rui Matos 2014-05-16 10:02:55 UTC
Yeah, I did go to the docs in the first place to be sure about this so
a comment sounds good indeed.

Attachment 275237 [details] pushed as 98a2ab2 - shell: Keep the filter terms cached
Attachment 275238 [details] pushed as 13abc75 - shell: Make search results sorting smarter
Attachment 276619 [details] pushed as 7d9da10 - display: Add "Monitor" to keywords
Attachment 276620 [details] pushed as 70dbd36 - search-provider: Use panel IDs as results instead of tree model paths