执行forcemerage常用API:
POST /my-index/_forcemerge
POST /myindex/_forcemerge?max_number_segme
nts=1
POST /myindex/_forcemerge?only_expunge_delete
s=true
PUT index_name
{
"settings": {
"index": {
"sort.field": "timestamp",
"sort.order": "desc"
}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date"
}
}
}
}
GET /index_name/_search
{
"size": 10,
"sort": [
{ "timestamp": "desc" }
]
}
ES会检查每个提前排好序的segment文件
的topN条doc返回,而不再对shard上所有
的segment文件进行遍历,大大降低查询耗
时。
GET filebeat-7.2.1/_search
{
"from": 0,
"size": 5000,
"_source": {
"includes": [
"region","host.name”
]
}
}
GET filebeat-7.2.1/_search
{
"from": 0,
"size": 5000,
"stored_fields": ["_none_"],
"docvalue_fields": [
"region","host.name”
]
}
?这里看到测试结果。提升有数10倍。