elasticsearch優化及查詢api

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

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

二、磁盤閾值ide

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"
    }
}'

三、修改副本數量url

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

四、刪除索引code

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

五、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"
                                                    }
                                            }
                                    }
                            }
                    }
            }
    }
}'
相關文章
相關標籤/搜索