views:

127

answers:

3

I'm building a "Narrow your results by" feature similar to Best Buy's and NewEgg's. What is the best practice for storing the user's filter selections in a URL that can be shared/bookmarked?

The obvious choice is to simply keep all the user's selections in the query string. However, both of these examples are doing something far more cryptic:

Best Buy: http://www.bestbuy.com/site/olstemplatemapper.jsp?id=pcat17080&type=page&qp=crootcategoryid%23%23-1%23%23-1~~q70726f63657373696e6774696d653a3e313930302d30312d3031~~cabcat0500000%23%230%23%2311a~~cabcat0502000%23%230%23%23o~~nf518||24363030202d2024383939&list=y&nrp=15&sc=abComputerSP&sp=%2Bcurrentprice+skuid&usc=abcat0500000

It appears they're assigning some unique value to the search and storing it temporarily on their side. Or perhaps wrapping their db id's in a bunch of garbage because they believe in security through obscurity?

Is there some inherent disadvantage to keeping things simple like this? www.mydomain.com?color=blue&type=laptop

So when I select a 17" screen size as a filter, it would simply reload the page with the additional query string tacked on: www.mydomain.com?color=blue&type=laptop&screen-size=17

Also, to clarify, I would likely use corresponding ids from the database in the URL to make validation and parsing easier/faster, but the question remains about whether there's some problem I'm missing in my simple approach.

Thanks in advance!

+1  A: 

I think the more human-readable manner, i.e. www.mydomain.com?color=blue&type=laptop&screen-size=17 is the better approach to take here. Just make sure you are sanitizing everything coming from the url before it gets to the database.

GSto
A: 

The query string has very reachable max length (255?), which is probably the reason for the serialization.

Paul Creasey
The practical length is 2048 per http://stackoverflow.com/questions/1344616/max-length-of-query-string-in-an-ajax-get-request, but yes, good point.
Cory House
+2  A: 

One of the first players in the faceted search domain was Endeca, and they are still used by many of the larger online stores (PC Connection, Home Depot, Walmart ...). You may want to take a look at their website. There is a Drupal plug-in for faceted search. Check out the demo.

I don't think the URL composition matters much, but I actually think presenting the parameters in a readable form may be dangerous. One of the advantages of using "Guided search" is that you can avoid producing empty result sets by not allowing invalid parameter combinations. If the query-string is user-editable, they can come up with invalid combinations, circumventing the guided search.

cdonner
Sometimes half the battle is just figuring out what term to Google - thanks for the tip on faceted search. I'd never heard the term.
Cory House