I am trying to add a text recommendation to a search bar that I am working on. I want the search bar to recommend future texts based on the texts that I have typed. My current idea is to put all the possible words in a massive tree and traverse the tree as I am typing. This sounds like a bad idea to me because it's going to be hard to weight the words. Are there any suggestions on how I should do this or how actual search bars do this? Thanks!