I am referring to the algorithm that is used to give query suggestions when a user types a search term in Google.
I am mainly interested in: 1. Most important resul
Take a look at Firefox's Awesome bar algorithm
Google suggest is useful, because it take the millions of popular queries + your past related queries into account.
It doesn't have a good completion algorithm / UI though:
tomcat tut
--> correctly suggest "tomcat tutorial". Now try tomcat rial
--> no suggestions )-:Google's exact algorithm is unknown, but it is said to work by statistical analysis of users input. An approach not suitable for most cases. More commonly auto completion is implemented using one of the following:
Take a look at completely, a Java autocomplete library that implements some of the latter concepts.
I think that one might be better off constructing a specialized trie, rather than pursuing a completely different data structure.
I could see that functionality manifested in a trie in which each leaf had a field that reflected the frequency of searches of its corresponding word.
The search query method would display the descendant leaf nodes with the largest values calculated from multiplying the distance to each descendant leaf node by the search frequency associated with each descendant leaf node.
The data structure (and consequently the algorithm) Google uses are probably vastly more complicated, potentially taking into a large number of other factors, such as search frequencies from your own specific account (and time of day... and weather... season... and lunar phase... and... ). However, I believe that the basic trie data structure can be expanded to any kind of specialized search preference by including additional fields to each of the nodes and using those fields in the search query method.