Comment 4 for bug 1337864

Revision history for this message
James Tait (jamestait) wrote :

This is already possible via the search API:

{
  "_links": {
    "first": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=department%3A%22games%22&page=1&size=2"
    },
    "last": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=department%3A%22games%22&page=35&size=2"
    },
    "next": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=department%3A%22games%22&page=2&size=2"
    },
    "self": {
      "href": "https://search.apps.ubuntu.com/api/v1/search?q=department%3A%22games%22&page=1&size=2"
    },
    "curies": [
      {
        "templated": true,
        "name": "clickindex",
        "href": "https://search.apps.ubuntu.com/docs/relations.html{#rel}"
      }
    ]
  },
  "_embedded": {
    "clickindex:recommendation": [],
    "clickindex:package": [
      {
        "price": 0,
        "icon_url": "https://myapps.developer.ubuntu.com/site_media/appmedia/2013/09/solitaire-games64.png",
        "title": "Solitaire Games",
        "name": "com.ubuntu.developer.labsin.solitaire-games",
        "_links": {
          "self": {
            "href": "https://search.apps.ubuntu.com/api/v1/package/com.ubuntu.developer.labsin.solitaire-games"
          }
        },
        "publisher": "Sam Segers",
        "content": "application"
      },
      {
        "price": 0,
        "icon_url": "https://myapps.developer.ubuntu.com/site_media/appmedia/2014/06/rockpaperscissorslogo_256.png",
        "title": "Rock Paper Scissors",
        "name": "com.ubuntu.developer.11ubuntucg.rockpaperscissors",
        "_links": {
          "self": {
            "href": "https://search.apps.ubuntu.com/api/v1/package/com.ubuntu.developer.11ubuntucg.rockpaperscissors"
          }
        },
        "publisher": "Brian Jaury",
        "content": "application"
      }
    ]
  }
}

However, I accept that this might not be optimal for a couple of reasons:

 - It requires a separate call to the index
 - It requires pagination support on the client

The second point can be mitigated by adjusting the size parameter accordingly to get things off the ground, but that's a temporary work-around - ultimately, the scope is going to have to support pagination, otherwise we'll be returning potentially thousands of results in a single response. It's not just the network usage that's a problem here, but the memory and processing overhead on the client.

The first point can be addressed on the server side by embedding clickindex:package resources in the department response. This is, in fact, the long-term plan. There was an unfortunate mix-up in terminology that led to "browsing search results by department" being misinterpreted as "browsing for arbitrary packages by department" - the former of which is not currently supported, the latter being expressly permitted - and so this embedding was de-scoped for RTM. I'm happy to do the work to support it now, with the caveat that pagination support will be added later.