I have a live search on my help page that searches our help database and returns the relevant results. I figure that a good way to decide what needs more documentation would be to log searches that return no results to our database.
Normally, this would be really simple, but that fact that it's a live search has made it a bit more tricky.
So when someone searches for:
- This search returns no results.
because it's a live search we get searches of:
- This s
- This search r
- This search returns n
- This search returns no results.
Obviously it would be best if we could only log the full phrase and not the partials.
So for now the way I'm just dumping all the searches into a table that looks like: (id int, search_string text, count int)
The only ways I can think of that might help would be to
Before we add a new row to the table do a like search of the search string against the searches in the table and if theres a match don't insert or increment the count. However, I expect this table will get really big and a like query like that would become really slow.
Write some javascript for if the input value hasn't changed in 2 seconds send a special live search with a flag that says to log it if it's a miss.
It seems to me that there must be a better way to handle this but I'm blanking on anything. Any ideas?