Hey everyone,
I have just been adding a feature to the search on my site and wondered what the best practice way of achieving it was?
I have a community site containing a search, which stores the criteria in session variables and displays 12 results per page (so each new page of results you go to it reruns the same database lookups but only pulls out the relevant results). This is arguably unecessary processing as it has to run effectively the same queries on each results page. Having the sessions variables allows users to return to their previous results from anywhere on the site.
I am adding a Previous/Next feature, where if you have done a search and are viewing a profile you can click Previous or Next (to take you to the previous or next profiles in the search). The problem this brings is that i then have to effectively run all the search queries on each profile page to ascertain the next and previous profiles.
What seems logical is to store search criteria in a database (which obviously makes for a more robust system anyway). To make this much more effective you then also have to store the search results (ids anyway) in a table which can be referenced directly, so you can easily retrieve the next/previous result without having to do all the search querying again.
What i can't quite understand is, on the basis the average search returns lets say 1000 results and people are searching pretty frequently, then won't this in itself be very ineffective, as for every search i will have to enter 1000 entries in my results table and then remove them when the search has expired?
I would really, really appreciate an idea of what the standard/best practice methodology is in this case, i appreciate i can store the sessions in the database as well, but this doesn't solve the issue of the results table. I am sure there is a standard, sensible way of dealing with this but i just cannot see it!!
Thanks so much for any thoughts you may have,
Dave