Trie 如何构建自动完成功能?

Trie 如何构建自动完成功能?,trie,application-design,web-application-design,Trie,Application Design,Web Application Design,特征如 比如说 我有一个名为人名的字段,当用户输入时,我们将显示与用户输入匹配的所有选项 我的第一个问题: which one should maintain trie tree, frontend, backend or both? No matter front end or back end, when will trie tree be loaded? If trie loaded on start, million of entities loaded take a lot tim

特征如

比如说 我有一个名为人名的字段,当用户输入时,我们将显示与用户输入匹配的所有选项

我的第一个问题:

which one should maintain trie tree, frontend, backend or both?
No matter front end or back end, when will trie tree be loaded?
If trie loaded on start, million of entities loaded take a lot time, and huge data in memory.
If trie loaded once user searched, each time user typed is a DB call and a Rest call, which also consumme a lot resources. And at first search, user will see no options till he did once, which is bad user experience.
第二个问题:

which one should maintain trie tree, frontend, backend or both?
No matter front end or back end, when will trie tree be loaded?
If trie loaded on start, million of entities loaded take a lot time, and huge data in memory.
If trie loaded once user searched, each time user typed is a DB call and a Rest call, which also consumme a lot resources. And at first search, user will see no options till he did once, which is bad user experience.
如果你有想法,期待了解