Snaps search not always same size

Bug #1731925 reported by Toto Bille
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Store Server
Fix Released
Undecided
Celso Providelo

Bug Description

When searching for a snap with page and size, the size is not always the same. There are a few different cases:

CURRENT BEHAVIOR

Search for web:

PAGE 1
curl -s -H "X-Ubuntu-Architecture: $ARCH" -H "X-Ubuntu-Frameworks: $FRAMEWORKS" -H 'Accept: application/hal+json' 'https://search.apps.ubuntu.com/api/v1/snaps/search?q=web&page=1&size=10'

-> size(result['_embedded']['clickindex:package']) = 10 OK

PAGE 2
curl -s -H "X-Ubuntu-Architecture: $ARCH" -H "X-Ubuntu-Frameworks: $FRAMEWORKS" -H 'Accept: application/hal+json' 'https://search.apps.ubuntu.com/api/v1/snaps/search?q=web&page=2&size=10'

-> size(result['_embedded']['clickindex:package']) = 10 OK

PAGE N
... OK

web is OK

Now search for core:

PAGE 1
curl -s -H "X-Ubuntu-Architecture: $ARCH" -H "X-Ubuntu-Frameworks: $FRAMEWORKS" -H 'Accept: application/hal+json' 'https://search.apps.ubuntu.com/api/v1/snaps/search?q=core&page=1&size=10'

-> size(result['_embedded']['clickindex:package']) = 10 OK

PAGE 2
curl -s -H "X-Ubuntu-Architecture: $ARCH" -H "X-Ubuntu-Frameworks: $FRAMEWORKS" -H 'Accept: application/hal+json' 'https://search.apps.ubuntu.com/api/v1/snaps/search?q=core&page=2&size=10'

-> size(result['_embedded']['clickindex:package']) = 8 NOK

PAGE 3
curl -s -H "X-Ubuntu-Architecture: $ARCH" -H "X-Ubuntu-Frameworks: $FRAMEWORKS" -H 'Accept: application/hal+json' 'https://search.apps.ubuntu.com/api/v1/snaps/search?q=core&page=3&size=10'

-> size(result['_embedded']['clickindex:package']) = 6 NOK

PAGE N
... NOK

core is not OK

EXPECTED BEHAVIOR

All page, except the last page, should have 10 (in this case) snaps in their search

Toto Bille (tbmb)
description: updated
Kit Randel (blr)
Changed in snapstore:
status: New → Confirmed
assignee: nobody → Kit Randel (blr)
Revision history for this message
Kit Randel (blr) wrote :

Hi Thomas, this behaviour is by design, as with the current implementation we are unable to guarantee fixed page sizes due to privacy filtering.

That being said, I think there is a change we can make to improve this significantly, resulting in the behaviour you would expect consistently for low page sizes. I'll let you know when we have a proposal for this work.

tags: added: snapfind
Celso Providelo (cprov)
tags: added: search
Revision history for this message
Celso Providelo (cprov) wrote :

Search batch-sizes are now constant (as requested) since the last store release:

{{{
$ echo "TOTAL: $(curl -s 'https://api.snapcraft.io/api/v1/snaps/search?q=core' | jq '._embedded["clickindex:package"] | length')" && for i in `seq 1 3`; do echo "PAG $i: $(curl -s "https://api.snapcraft.io/api/v1/snaps/search?q=core&size=10&page=$i" | jq '._embedded["clickindex:package"] | length')"; done
TOTAL: 27
PAG 1: 10
PAG 2: 10
PAG 3: 7
}}}

There are still use-cases that can't have guaranteed batch sizes as documented in https://docs.google.com/document/d/1kWV5PVVfYwU2qq4JrFkF_uI--2A-fCb2_MPYjhvGyKI/edit

Changed in snapstore:
status: Confirmed → Fix Released
assignee: Kit Randel (blr) → Celso Providelo (cprov)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.