views:

77

answers:

2

We are building a large search interface with close to 70 properties. Most of these properties are boolean (only hold 0 or 1), around 12 are with int values and some are string.

goal: http://www.example.com/q/test_search/fdgREGd3vfS323
want to avoid: http://www.example.com/q/test_search/?val_12=1000&val_120=0&val_4=XY....

Our goal is to have a short url which will hold all search properties, thus making it possible to store/send exact search data just by remembering the url.

I know this can all be done with many parameters in the url string, but my boss is persistent.

We have figured how to represent boolean values:

Map values to a binary representation ( 00010101011) with each position representing one variable. We pass this string encoded to a shorter counterpart (AB) in e.g. Hex.

But when it comes to properties, that hold values, we havent decided how to procede. Any ideas?

+2  A: 

You can simplify it even more. If database is not a problem, you can store the searches of the people in the databse, and give out urls of some kind like this:

user_searches:
 search_id | prop1 | prop2 | prop3 | .... | propN

and give the users url like:

http://example.com/search/(search_id)

I prefer using this way, because it's invisible from user's end point what is happening, it keeps the url short and you can keep (easily) track of what people are searching, in case you want to optimise your site for usability :).

[edit] additionally you can use a hash for the (search_id) so searches would not be so easily guessed by other users.

bisko
A great idea, will have to give this one some thought
gregor
A: 

If your values are finite and static, assign a number to them.

If the combination of all possible search parameters is finite, there's also the option to hash the whole thing and use that hash as your restful URL parameter.

Robert Elwell
Thought about that, but we dissmissed this option because of the length of the url
gregor