For example, if you type something in upper-right google/yahoo search box in firefox there will be some kind 'suggested auto complete' sort of thing.
Another example is in youtube search box and Stackoverflow tags edit box just below this question preview. How do they work? What technology behind 'em?
If you're signed in to your Google Account and have Personal results turned on, you might also get personalized predictions and recommendations in Google Search. If you don't want to get these predictions and recommendations, turn off Personal results.
Autocomplete is a search feature where the search engine predicts the user's query and provides suggestions as the user types. The user can select any of the autocomplete suggestions and be taken to results without having to manually type every character.
To create predictive search suggestions, you overlap two containers (a search box and a predictive box), then send your user's current query to your suggestions index at every keystroke. Based on the query, the predictive box displays and consistently updates the first result from the suggestions.
What technology behind 'em?
In case you are wondering which data structure is being used underneath then its called "trie" and for using less space compared to tries you can use "DAFSA"
How do they work?
both are implemented as a tree, where each node of tree corresponds to one character in a string and the character which appears before is parent of character which appears later e.g. The strings "tap", "taps", "top", and "tops" stored in a Trie (left) and a DAFSA (right),so as you begin to type tap..the tree is traversed based on the characters typed and shows the suggestions based on some weight assigned to each word, weight may be assigned based on usage frequency of the word.
Looking up string in worst case is O(m) time where m is the length of string.
Image is being referenced from the wikipedia articel : DAFSA,trie
It's quite simple.
Client side:
Server side:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With