Maybe you're interested About this site or in some of my Projects or Articles. You might even be interested About me or My Friends. If all else fails head back Home.

Morethanseven is where plays with the web

Resourceful Vs Hackable Search URLs

April 18th, 2008

I often end up pondering URL design given a moment and something that keeps coming up is hackable search queries. But first a very quick primer on the idea of resourceful design.

REST is a series of architectural principals more than a defined architecture. The Resource Orientated Architecture builds on those ideas with a series of concrete guidelines put down by Sam Ruby for designing RESTful systems. The simple version is that you try to design your system around resources represented by URLs.

I’d thoroughly recommend reading RESTful web services whenever you get a moment as this subject is covered in detail.

Flickr isn’t a truly resourceful design but it does have many of the hallmarks. For example the URL that describes me is at:

http://flickr.com/people/garethr

When it comes to searching on flickr we have:

http://flickr.com/search/?w=all&q=pubstandards&m=text

The pattern of using a query string argument named q to pass a search string is pretty common. One of the guidelines mentioned as part of the ROA discussed query strings:

Query string parameters are appropriate if they are inputs to a Resource which is an algorithm. Otherwise, these values should be moved into the URI.

Search is definitely algorithmic. Now you could maybe argue that a global search should be done on the root of a site, with specific resource searches on the resource in questions. eg. /people/?q=. This would likely work fine but require some behind the scenes complexity as well as probably not being as obvious to the end user. Global searches are in many cases much more common that restricted searches and even in resourceful designs the root of the site (ie. the home page) might not act as a list of available site resources. A notable exception might would have to be the excellent BBC Programmes site which is basically one big semantic catalogue.

But we have another kind of URL that’s cropping up for search results, one that treats the URL much more like a fundamental part of the user interface for search. An example from a site I use all the time is The Accessible UK Train Timetable which allows for URLs like the following:

http://traintimes.org.uk/newcastle/london

You can basically squash all the search parameters from the form into the URL, meaning you can easily bookmark search results. Note however the actual content is likely to change. The above example for instance would use the current time to get a list of trains from Newcastle to London. In an hours time the results will be different.

Another good example would be the new Yahoo! UK TV listings which has URLs like these:

http://uk.tv.yahoo.com/listings/bbc-two/2008-04-17/
http://uk.tv.yahoo.com/listings/itv1/2008-04-17/21-00/

Again this is really a search query, or at least specifying the time and date is. In some ways it’s the return of the command line – allowing searches to be run very quickly from a textual interface.

Now, both these approaches treat URLs with the respect they deserve. But they do have the potential to clash somewhere in the middle if care isn’t taken. The Accessible Train Times site is a single purpose site which just does searches while BBC Programmes does feature a search engine but it’s just the global BBC search which takes you off site. And if that wasn’t enough potential competition then a question raised by Simon at The Highland Fling regarding URL design and the search engine optimisation crowd go me thinking too. From being a somewhat niche area of interest URLs might just become a sort after part of a good website design – fought over by the varying disciplines of modern web design and development.

Popularity: 10%

Tagged , , ,

8 Responses to “Resourceful Vs Hackable Search URLs”

  1. Very interesting. I’ve had a post brewing about URL structure for a while, but haven’t gotten around to distilling all my thoughts into a coherent wrap-up yet. I’m very interested in URL as command-line, but also trying to combine that with effective SEO. It’s tricky to do both, but I’ve got a solution in my head that I want to blog about.

    I had not thought to extending the idea to search queries though.

  2. Im still not sure how I feel searches should be constructed. I have done them both ways, one in a hackable URL format – so people could type in whatever like /books/{book name or isbn}, /authors/{author name}, etc. I think it worked out well, there were a few considerations on the backend to tie everything together properly.

    I just like pretty URL’s, no matter what – so I try and avoid the ‘q’ – even though it has been considered pretty standard.

    @Matt Wilcox
    The tricky part in regards to SEO is having the content change, or having duplicate content – so – while wanting to have your searches indexed, you have to balance all of that. That’s just a small part of it all.

  3. It’s good to know that I’m not the only one who obsesses about URL structure! I wrote a series of blog posts on the topic a couple of months ago:

    http://blogs.edgehill.ac.uk/webservices/tag/badurls/

  4. @Nate Not sure I see the /books/{book-name} example as a search as such, more inline with the idea of resources (ie. individual entities having a single URL). A search might be for an incomplete term or for a book on which you know the subject, and it might return multiple results. So /books/?q={subject} for instance.

    Good point regarding duplicate content though, especially where search results can return large chunks of the site content from elsewhere.

  5. [...] Resourceful Vs Hackable Search URLs [Morethanseven] A nice article considering the design of RESTful URL including a look at including search strings in URLs. (tags: URL REST) [...]

  6. @Nate

    Indeed, the impact of different
    URLs for the same page content has occurred to me. As far as I know though, search engines will penalise identical content only if the top level domain is different. But I definitely would want to know if that’s wrong. I’ve not been able to dig up any information on it. Ideally I want two URL solutions to lead to the same page. I’ll blog later tonight on it I think.

  7. This is always a source of mindwrangling for me. Query strings imply name value pairs, which sometimes feel/more/appropriate/than/this. URLS imply hierarchy, which is usually the right choice.

    Different types of searches demand different URLs. The ‘simplest case’, ?q=keyword+search feels wrong to me as the name part of the name/value pair (“q”) is completely irrelevant… /search/keyword+search feels better, or possibly /search/keyword/keyword+search (alongside examples such as /search/category/coconuts and /search/legs/3), but this breaks down if your search is across a number of criteria… It’s in this case which a query string makes me happier (for example: /search/?keywords=ham+jam&category=fillings&cost=299)

    In the examples above, I don’t like the train times. It feels non-obvious, and London is not subordinate to Newcastle (or vice versa)... ?from=newcastle&to=london would please me more.

    I think the Y! TV URLS are spot on though.

  8. Don’t forget that you can have parameters in path segments. Now how this gets used depends a lot on what you’re trying to do, but for instance: http://traintimes.org.uk/from=newcastle;to=london/ has many advantages in that you can further compose it: http://traintimes.org.uk/from=newcastle;to=london/today/last for instance.

    Of course, generating these in plain HTML is painful (albeit not impossible – you can happily have /search?from=newcastle&to=london redirect to /from=newcastle;to=london/ ). I guess there’s a useful distinction between a URI that can act as a view, and a search resource that can point you straight to the right view.

Leave a Reply