elasticsearch優化及查詢api

1、改變ES默認深度分頁的index.max_result_window 最大窗口值

curl -XPUT http://127.0.0.1:9200/my_index/_settings -d '
{ 
    "index" : { 
        "max_result_window" : 500000
    }
}'

2、磁盤閾值

curl -XPUT http://127.0.0.1:9200/_cluster/settings -d '
{
    "transient":{
        "cluster.routing.allocation.disk.threshold_enabled":true,
        "cluster.routing.allocation.disk.watermark.low":"75%",
        "cluster.routing.allocation.disk.watermark.high":"90gb",
        "cluster.info.update.interval":"30s"
    }
}'

3、修改副本數量

curl -XPUT http://127.0.0.1:9200/index/_settings -d '
{
    "index":{
        "number_of_replicas":0
    }
}'

4、刪除索引

curl -XDELETE http://127.0.0.1:9200/index-`date -d "1 week ago" + '%Y-&m-%d'`

5、aggs多字段聚合

curl -XGET 'http://localhost:9200/index/field/_search?pretty' -d '{
    "size":0,
    "aggs":{
            "tag1":{
                    "terms":{
                            "field":"keyword1",
                            "size":num1
                    },
                    "aggs":{
                            "tag2":{
                                    "terms":{
                                            "field":"keyword2",
                                            "size":num2
                                    },
                                    "aggs":{
                                            "tag3":{
                                                    "avg":{
                                                            "field":"keyword3"
                                                    }
                                            }
                                    }
                            }
                    }
            }
    }
}'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章