zoukankan      html  css  js  c++  java
  • Elasticsearch常用API

    Note:以下API基于ES 5x,6x/7x可能略有不同,具体查看官方文档

    ES常用API

    # 查看集群node
    curl "http://localhost:9200/_cat/nodes?v"
    
    # 查看索引
    curl "http://localhost:9200/_cat/indices?v"
    curl "http://localhost:9200/_cat/indices/api*?v"
    
    # 打开一个索引
    curl -s -XPOST "http://localhost:9200/my-esdata/_open?pretty"
    
    # 关闭一个索引
    curl -s -XPOST "http://localhost:9200/my-esdata/_close?pretty"
    
    # 删除一个索引
    curl -XDELETE "http://localhost:9200/my-esdata"
    
    # 设置alias
    curl -X POST "localhost:9200/_aliases?pretty" -H 'Content-Type: application/json' -d'
    {
        "actions" : [
            { "add" : { "index" : "test1", "alias" : "alias1" } }
        ]
    }'
    
    # 查看alias
    curl "localhost:9200/_cat/aliases?v"
    
    # thread
    curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
      "index.merge.scheduler.max_thread_count" : "1",
      "index.translog.flush_threshold_size" : "512m"
    }'
    
    # 设置副本为0,可快速批量导入
    curl -XPUT "localhost:9200/_settings" -d '
     {
    "index":{
    "number_of_replicas":0
    }
    }'
    
    # 关闭合并限流,使导入更快、在导入完成后改回 merge
    curl -XPUT "localhost:9200/_cluster/settings" -d '{
        "persistent" : {
            "indices.store.throttle.type" : "none" 
        }
    }'
    
    # 更改threadpool
    curl -XPUT "localhost:9200/_cluster/settings" -d '{
        "thread_pool": {
    		"thread_pool.index.size" : "fixed"
    		"thread_pool.bulk.size" : "32"
    		"thread_pool.index.queue_size" : "800"
        }
    }'
    
    # 设置刷新频率
    PUT /_all/_settings
    {
        "index" : {
            "refresh_interval" : "60s"
        }
    }
    
    # 查看shard分布
    curl -XGET "http://localhost:9200/_cat/shards"
    
    # 手动移动分片
    curl -XPOST "http://localhost:9200/_cluster/reroute" -d '{
      "commands" : [ {
            "move" :
                {
                  "index" : "my-esdata", "shard" : 3, "from_node" : "localhost", "to_node" : "10.1.1.10"
                }
            }
      ]
    }'
    

    ES Template API

    # 集群设定
    curl -XPUT 'http://localhost:9200/_cluster/_settings?preserve_existing=true' -d '{
    "index": {
    "translog.durability" : "async",
    "translog.flush_threshold_size" : "1g",
    "translog.sync_interval" : "60s",
    "store.throttle.type": "none"
    }
    }'
    
    # 设置全局shards数量
    curl -XPUT 'http://localhost:9200/_all/_settings?preserve_existing=true' -d '{
      "index": {
      "number_of_shards" : "4"
      }
    }'
    
    # 查看所有template基本信息
    curl -XGET "http://localhost:9200/_cat/templates?v"
    
    # 查看指定template信息
    curl -XGET "http://localhost:9200/_template/my-esdata?pretty"
    
    # 查看所有template详细信息
    curl -XGET "http://localhost:9200/_template?pretty"
    
    # 设置my-esdata-template模板
    # index name匹配为my-esdata*则使用此template
    # template中参数优先与全局参数
    curl -XPUT "http://localhost:9200/_template/my-esdata-template" -d '{
    "template" : "my-esdata*",
      "settings" : {
      "number_of_shards" : 4,
      "number_of_replicas" : 0,
      "refresh_interval" : "60s",
      "translog.durability" : "async",
      "translog.flush_threshold_size" : "1g",
      "translog.sync_interval" : "60s",
      "store.throttle.type": "none",
      "store.throttle.max_bytes_per_sec": "100m",
      "index.routing.allocation.total_shards_per_node": "1"
      }
    }'
    
    # 设置my-test模板
    # index name匹配为**则使用此template
    # template中参数优先与全局参数
    curl -XPUT "http://localhost:9200/_template/my-test-template" -d '{
    "template" : "*my-test*",
      "settings" : {
      "number_of_shards" : 4,
      "number_of_replicas" : 0,
      "refresh_interval" : "60s",
      "translog.durability" : "async",
      "translog.flush_threshold_size" : "1g",
      "translog.sync_interval" : "60s",
      "store.throttle.type": "none",
      "store.throttle.max_bytes_per_sec": "100m",
      "index.routing.allocation.total_shards_per_node": "1"
      }
    }'
    
  • 相关阅读:
    python网上开发执行环境
    bt5全称是Back Track five,是继BT3,BT4之后的最新版,这是一个linux环境的便携系统,可以放到U盘或者硬盘中启动,对本身硬盘没有影响,无需在本地安装。
    ubuntu安装mysql的步骤和配置总结
    Django 安装MySQLdb模块
    OpenCV3编程入门笔记(一)
    论文笔记---Deblurring Shaken and Partially Saturated Images
    win7 64位操作系统 电脑桌面出现this computer is being attacked的窗口
    论文笔记(一)---翻译 Rich feature hierarchies for accurate object detection and semantic segmentation
    OpenCV3计算机视觉Python语言实现笔记(五)
    OpenCV3计算机视觉Python语言实现笔记(四)
  • 原文地址:https://www.cnblogs.com/ioops/p/14313363.html
Copyright © 2011-2022 走看看