提升 Elasticsearch(ES)检索速度,需要从索引设计、查询优化、集群配置、硬件与架构几个维度入手。下面按优先级和可操作性整理一份实用清单:
keyword,不要都用 text"enabled": false
"index": false
"norms": false"index_options": "docs"_source(谨慎):"_source": { "enabled": false }
{
"query": {
"bool": {
"filter": [
{ "term": { "status": "active" } }
]
}
}
}
wildcard / prefix / regexp 很慢index_prefixes 或 ngram_source 返回"_source": ["id", "title"]
track_total_hits"track_total_hits": 10000
避免全量统计
search_afterfrom + size 过深preference 固定分片"preference": "user_123"
提高缓存命中率
runtime fields 谨慎index.search.slowlog.threshold.query.warn: 1s
GET /index/_search
{
"profile": true,
"query": { ... }
}
✅ filter 代替 query
✅ keyword 替代 text
✅ 减少 _source
✅ 控制分片大小
✅ 增加 OS cache
✅ 开慢查询日志
如果你愿意,可以:
我可以帮你做针对性优化方案。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。