Snap find produces inconsistent search results

I’ve found some odd behaviour in snap find:

$ snap find s | wc -l
89
$ snap find se | wc -l
98

Entering a one character search for ‘s’ returns 88 snaps, but then entering ‘se’ returns 97 snaps. I would have expected that entering fewer characters would return more results rather than less. Any ideas what’s happening here?

Hi James! Did you actually look at the list of returned results?

the first option finds all snaps whose name begins with s, while the second one finds snaps whose name contains se anywhere, including descriptions.

I imagine this behavior is by design, as finding snaps by a single letter is bound to be pretty useless; constraining that to only the first letter of the name sounds reasonable to me.

well, without knowing any of the results, how can there be less snaps with “s” than there are snaps with “se” given that one should be a subset of the other …

Hi! Because fewer snaps begin with s. Imagine this universe of snaps:

sick sad base insert consequent

2 snaps begin with “s” (snap find s) 3 snaps contain “se” (snap find se)

Or you could, you know, have done what I suggested and looked at the actual lists of returned results :wink:

The switch between “begins with” and “contains” seems really inconsistent. I can’t think of any search that works that way and seems unintuitive. Feels like a bug to me, not a desired feature.

1 Like

If you feel it’s a bug, I’d appreciate if you could file it as such:

Thanks!

Done: https://bugs.launchpad.net/snapstore/+bug/1722821