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

When there are no matches, appstreamcli returns all items instead of none #237

Closed
Pointedstick opened this issue May 22, 2019 · 4 comments
Closed

Comments

@Pointedstick
Copy link

Pointedstick commented May 22, 2019

$ appstreamcli search "coco" | wc -l
6
$ appstreamcli search "" | wc -l
9048
$ appstreamcli search "2+2" | wc -l
9048

KDE's KRunner has an AppStream runner that searches for apps matching the user's query, which may not even have anything to to with apps. Because of this bug, when there are no AppStream matches (e.g. because the search term is a mathematical expression), we get back all items it knows about instead of none, causing a performance bottleneck for other KRunner runners that has resulted in user bug reports. See https://bugs.kde.org/show_bug.cgi?id=406384.

Version:

$ appstreamcli --version
AppStream version: 0.12.6
@ximion
Copy link
Owner

ximion commented Jun 10, 2019

Returning all items is the default behavior in case the search string is invalid (e.g. when it contains only invalid characters, is too short or has a length of zero). The intent of this behavior is to give a hint to the user to refine the search by specifying it (since a ton of results will be shown at random).

It may make sense to leave the decision to the client though, especially with the new search behavior that just landed in master.
I could think of only returning all components when there is clearly invalid input (NULL or a zero-length string) and return no matches in all other cases.
That should also not break any user of the library who may depend on the current behavior.
What do you think?

@Pointedstick
Copy link
Author

Hmm, when a search returns no results, I think the better hint to the user that they need to refine the search parameters is actually returning no results. :)

But yes, as a compromise, returning all results only for invalid input would make sense though, assuming "invalid" is broad enough. For our use case in KDE, we'd want "2+2" to be considered valid and return no results (unless of course there's an app called 2+2 lol.

@ximion
Copy link
Owner

ximion commented Jun 16, 2019

Hmm, when a search returns no results, I think the better hint to the user that they need to refine the search parameters is actually returning no results. :)

Depends on how you look at it, I guess... This behavior was copied over from the old Ubuntu Software Center in the very early days of AppStream, and I guess it made sense back then.

After thinking about it some more, I changed the code now to match all the things on a very broad query (as in "one letter searches") and in any other case when we can not acquire enough tokens from a search query do the expected thing and match nothing.
This should be enough compatibility to not cause issues with existing clients, but most importantly I think this behavior makes the most sense.
Thanks for raising this issue!

@ximion ximion closed this as completed in 0d74990 Jun 16, 2019
@Pointedstick
Copy link
Author

Thanks @ximion! We'll see if that's enough. I'm a little worried that "return everything for one letter queries" will still be a problem because it means the moment the user types a single character into KRunner, the results list will become packed with apps that all disappear once a second character is typed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants