java - 这种功能怎么实现?(搜索框自动补全+热词结果统计)
阿神
阿神 2017-04-17 17:42:07
0
6
573

类似这样,输入关键字,然后自动补全,返回相关热词+结果统计,我使用solr的facet功能,但是返回的结果,都是分的很细的词,比如头戴式(2),耳机(10),而不是头戴式耳机(4)。

所以,我想问一下,图中的效果是怎么实现的,后台方面要做哪些设计?

ps:举例是素材来着小米官网

阿神
阿神

闭关修行中......

reply all(6)
Ty80

Listen to the onkeyup event, send an Ajax request to the background, pass the entered keywords to the background, perform fuzzy matching in the background, and return the array to the front end;
Pay attention to two places here, the first is the onkeyup event of the front end, here is the function Throttling to prevent frequent requests to the background, portal: http://www.cnblogs.com/dolphinX/p/3403821.html; the second is database optimization, the searched fields need to be indexed and cached, here There are a lot of things involved, so you need to find relevant information by yourself;
The last thing is about the front-end effect implementation. There are many jquery plug-ins. You can find them by searching Baidu’s automatic completion. Here are a few for you: http://jq22. com/search?seo=%E8%87%AA%E5%8A%A8%E8%A1%A5%E5%85%A8

左手右手慢动作

angular can be automatically bound

刘奇

Tell me a rough plan
First record the words searched by the user. Each user search is recorded separately and stored in the database (you can filter here or import some words yourself)
Convert Chinese to Pinyin before storing in the database and save it for fuzzy search
Scheduled tasks update the number of records in the index for each search term (this may not be possible in real time)
You can use some jquery plug-ins at the front desk, such as autocomplete in jquery-ui
The actual effect can be seen at www.cnal.com Search

黄舟

There is a jq.autocomplete plug-in. You can take a look at the source code and then develop it again.

伊谢尔伦

Implementing an intelligent prompt function requires a lot of knowledge such as ajax, database, jsp/php, algorithms, etc.
If the amount of data is large, special optimization is required
It is not cost-effective to spend too much effort on a small function
I used 92find.c-o-m Search box smart prompt function hosting service,
With just one line of javascript code, you can realize all the functions of Baidu and Taobao search box prompts
For example: Chinese character pinyin matching, pinyin prefix matching, fuzzy search, intelligent fault tolerance, and you can also customize prompt vocabulary and its Sorting weight
It only takes five minutes for my website to deploy an input prompt function that is as powerful and easy to use as Baidu and Taobao
It is also compatible with IE, Firefox, Safari, Chrome, and Opera browsers
It is compatible with ios, Android, and Windows

刘奇

Implementing an intelligent prompt function requires a lot of knowledge such as ajax, database, jsp/php, algorithms, etc.
If the amount of data is large, special optimization is required
It is not cost-effective to spend too much effort on a small function
I used 92find.c-o-m Search box smart prompt function hosting service,
With just one line of javascript code, you can realize all the functions of Baidu and Taobao search box prompts
For example: Chinese character pinyin matching, pinyin prefix matching, fuzzy search, intelligent fault tolerance, and you can also customize prompt vocabulary and its Sorting weight
It only takes five minutes for my website to deploy an input prompt function that is as powerful and easy to use as Baidu and Taobao
It is also compatible with IE, Firefox, Safari, Chrome, and Opera browsers
It is compatible with ios, Android, and Windows

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template