文章目录
- 搜索建议
- 搜索高亮
- 前端防抖节流
- 接口稳定性优化
搜索建议
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-suggesters.html
GET+post_v1/_search
{
"query": {
"match": {"content" "鱼皮不欠费" }
},
"highlight": {
"fields": {
"content": {
"pre_tags": ["<h1>"], "post_tags": ["</h1>"]
}
}
},
"suggest": {
"my-suggestion": {
"text": "鱼皮不欠费",
"term": {
"field": "content"
}
}
}
}
搜索高亮
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/highlighting.html
高亮,建议,都可以从返回值里拿到
前端防抖节流
lodash工具:
节流:每段时间最多执行x次(比如服务器限流)
https://www.lodashjs.com/docs/lodash.throttle
防抖:等待一段时间没有其他操作了,才执行操作(比如输入搜索)
https://www.lodashjs.com/docs/lodash.debounce
接口稳定性优化
https://github.com/rholder/guava-retrying
解决调用第三方接口不稳定(比如该项目调用的bing接口)
接口稳定性保障:Guava Retrying重试机制