Welcome Guest, Not a member yet? Register   Sign In
search as a hash
#1

[eluser]thurting[/eluser]
Hi,

I notice that the search feature on this forum seem to store the queries in a hash table and present the hash in the result URL. I was wondering if anyone could give me insight into why this is done? Thanks.
#2

[eluser]Alex007[/eluser]
It's a pretty common way of doing a search script, when a user submits a search, you store the results in a table, along with a unique search ID.

That way, when the use goes back and forth in your search results pages, there's no load on the database, you just return a different range of the already-known results.

Otherwise that would mean you'd have to search again everytime, and discard the first x results according to the current page.

From time to time you clean up the old search results, with a CRON job or as a part of your search script.
#3

[eluser]Derek Allard[/eluser]
Additionally, if the string is hashed, you can submit anything into it, including characters that normally wouldn't make it through the xss screening of CI, such as % signs and "stuff"
#4

[eluser]thurting[/eluser]
Ok. I see - def. helpful to permit disallowed chars and decrease the load on the server. A couple of questions though...

In what format do you store the results? I imagine that for a large database storing the entire recordset may take up a lot of space.

If you store the results in a table, then they are no longer dynamic. Can't a problem arise if a user bookmarks a search page and returned to it later - there is a potential they will not see any relevant results that may have been created after the initial search.

Quote:Otherwise that would mean you’d have to search again everytime, and discard the first x results according to the current page.

Why is this? Can't you just use a LIMIT based on variable that holds current page value?

Thanks.
#5

[eluser]CodeOfficer[/eluser]
I asked this question once before and got squat for an answer. Thanks for clarifying derek and alex. I would also love to see thurting's last few questions answered if you could elaborate more. Thx so much!
#6

[eluser]Michael Wales[/eluser]
It does cause some issues - try searching for a term and then passing the URL off to a friend - they can't access it.

Personally, I think a hashing and comitting the results to a database is a good solution for a 24 hour timespan (depending on how active your forum is). But, the search controller needs to query the database for that search term and/or the hash and share it amongst all users - not just the one that searched for the term.




Theme © iAndrew 2016 - Forum software by © MyBB