Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create autosuggest to get keywords as fast as google search or live search

I am creating auto suggest function in my website search box, every time the user press a new key, javascript call a webservice on the server side to get 10 most relevant keywords from the db and gives to the javascript again, and javascript populate the search autosuggest list.

My function is not too slow, but comparing to what live.com or google.com doing its veryyyy slow, i tested them and really i feel that they are getting the keywords from my PC not from their servers.

How they get keywords very fast like this, and sure they have million million times my keywords?
there is a famous style to do like this?
Also using my firebug, i found that they are not calling webservice "may be calling by a way i am not aware", but i found in the Net tab that a new get is happening.

like image 633
Amr Elgarhy Avatar asked Dec 01 '22 12:12

Amr Elgarhy


1 Answers

Not sure where you're looking, but certainly on live.com I get a request for each letter:

Firbug Net Console - AutoComplete

As you can see, there's very little coming back across the wire - 500B - that's what you're aiming for - a lean web service that returns the minimum you need to display that back to the user.

Then on top of that, as the others have said, cache previous responses, etc.

Not that the results often aren't alphabetical, and so if you don't display your ordering criteria, you can work on the principle of "Something now is better than completely accurate later".

like image 136
Zhaph - Ben Duguid Avatar answered Dec 05 '22 02:12

Zhaph - Ben Duguid