ubuntu / app-center

App Store for Ubuntu made with Flutter ๐Ÿงก ๐Ÿ’™
GNU General Public License v3.0
640 stars 116 forks source link

search - show results matching the query on top #1203

Closed anasereijo closed 1 year ago

anasereijo commented 1 year ago

In this specific example, when search for the query 'mail', the only result with that partial query is not showing up as the first result. Is there a way to fix this?

Screenshot 2023-03-31 at 11 11 38
Feichtmeier commented 1 year ago

this should be fixed in the snap servers

anasereijo commented 1 year ago

this should be fixed in the snap servers

@Feichtmeier I am in touch with the snap store team about this. Could you please let me know what API call you used for this? Thank you

anasereijo commented 1 year ago

Seems that the website does a better job on results, I think that's why they are asking about the API call

Screenshot 2023-03-31 at 14 51 42
Feichtmeier commented 1 year ago

we are using a service class here that just calls snapd.dart find

https://github.com/ubuntu-flutter-community/software/blob/main/lib/services/snap_service.dart#L138

here

-->

https://github.com/canonical/snapd.dart/blob/main/lib/src/snapd_client.dart#L1158

So I assume since we do not sort the search in any ways as far as I remember (:older_man: ), this issue must be either in the snap daemon or snapd.dart

Better ask @robert-ancell then or @d-loose

Roadmaster commented 1 year ago

The Snap Store server does return things in what seems to be the proper order; specifically, mailspring is the first match. Test it yourself :)

curl -H "Snap-Device-Series: 16" "https://api.snapcraft.io/v2/snaps/find?q=mail&fields=title,summary,media,publisher" | jq . |

to show-and-tell:

$ curl -sH "Snap-Device-Series: 16" "https://api.snapcraft.io/v2/snaps/find?q=mail&fields=title,summary,media,publisher" | jq .results[0].name
"mailspring"

So:

  1. I'm using a very simple query with just a "q" parameter. The linked dart code shows me how the service is called but I don't know which parameters are passed specifically (since I see most of them are optional; I'd need to get info from an actual call, e.g. is a section being specified?) but I'm fairly sure even if it was the case, the results come properly ordered from the server.
  2. I don't know if/how snapd reorders these results before passing them out via its own, local API.

But to confirm, this does not seem to be an issue stemming from the Snap Store servers.

robert-ancell commented 1 year ago

snapd.dart is returning the results in the order as returned from snapd.

$ dart example/find.dart mail
Name                                 Version                Publisher           Summary                                                                                                                          
mailspring                           1.10.8                 foundry376          The best email app for people and teams at work                                                                                  
maildir-utils                        1.8.14                 alexmurray          Maildir indexer/searcher with an Emacs UI                                                                                        
zbctl                                8.1.5                  mail-falko-menge    zbctl is the command line interface to interact with Camunda Platform 8 and Zeebe 

You can contact snapd directly with curl --unix-socket /var/run/snapd.socket http://localhost/v2/find?q=mail| jq . and see the same order.

anasereijo commented 1 year ago

Just checked again, and today is returning the results as it should ๐Ÿค”

Screenshot 2023-04-04 at 16 04 55
d-loose commented 1 year ago

I can't reproduce the original issue - the results always show in the expected order. Is this still an issue for anyone? @anasereijo?

Jupi007 commented 1 year ago

I just tested it and I can't reproduce it. I got the exact same result as the snapcraft website.

anasereijo commented 1 year ago

Seems that it was a glitch, and it's working fine. @d-loose if there's nothing you can do to investigate it further, you can close it. Thank you!

d-loose commented 1 year ago

Thanks, feel free to re-open it, if you encounter it again!