What is the best URL strategy to handle multiple search parameters and operators?
Posted
by Jon Winstanley
on Stack Overflow
See other posts from Stack Overflow
or by Jon Winstanley
Published on 2010-04-20T12:45:49Z
Indexed on
2010/04/21
8:33 UTC
Read the original article
Hit count: 309
Searching with mutltiple Parameters
In my app I would like to allow the user to do complex searches based on several parameters, using a simple syntax similar to the GMail functionality when a user can search for "in:inbox is:unread" etc.
However, GMail does a POST with this information and I would like the form to be a GET so that the information is in the URL of the search results page.
Therefore I need the parameters to be formatted in the URL.
Requirements:
- Keep the URL as clean as possible
- Avoid the use of invalid URL chars such as square brackets
- Allow lots of search functionality
- Have the ability to add more functions later.
I know StackOverflow allows the user to search by multiple tags in this way:
However, I'd like to also allow users to search with multiple additional parameters.
Initial Design
My design is currently to do use URLs such as these:
- http://example.com/search/tagged/c+sql/searchterm/transactions
- http://example.com/search/searchterm/transactions
- http://example.com/search/tagged/c+sql
- http://example.com/search/tagged/c+sql/not-tagged/java
- http://example.com/search/tagged/c+sql/created/yesterday
- http://example.com/search/created_by/user1234
I intend to parse the URL after the search
parameter, then decide how to construct my search query.
Has anyone seen URL parameters like this implemented well on a website?
If so, which do it best?
© Stack Overflow or respective owner