How to realize the associative word function of the search box

does this function require front and rear cooperation? Or can it be completed as long as the front end?
the requirement is to fill in the project name. Multiple project names automatically appear in the box below. Click on the input box above, and the input box above completes the interface http://suggestion.baidu.com/su found on the
network, but the data called out by this interface ajax does not contain the project name we need

.

Thank you for giving me an answer. The first floor is more in line with my inner thoughts and my current technical level, so I adopted him. Thank you very much! Thank you! Thank you! Thank you!


before and after cooperation, you are no longer associated with

that link belongs to Baidu.

when the front end detects input onchange, it goes to the back end to query the matching string, and the back end returns you an array containing the results sorted by relevance

.

first:

  • the amount of data is very small so that all the data can be load to the client and then write the logic in the front end
  • backend cooperation is required when there is a large amount of data

secondly, the trie tree is used for the implementation of the word storage data structure, so that the fast retrieval can be carried out, and the back end is only responsible for searching according to the input. The front end listens to the input box and enters the content after the ajax is submitted to the backend for completion in a few milliseconds.

related references: twitter's js library typeahead.js

Menu