elasticsearch-head插件基本使用

1. 查看搜索setting信息

  

mp_index/_settings

2. 设置分片数量

3, 修改数据刷新间隔

{
  "refresh_interval": "30s" # -1 关闭
}

# 设置为30秒刷新频率

refresh_interval 可以在既存索引上进行动态更新。 在生产环境中,当你正在建立一个大的新索引时,可以先关闭自动刷新,待开始使用该索引时,再把它们调回来:

注意:

refresh_interval 需要一个 持续时间 值, 例如 1s (1 秒) 或 2m (2 分钟)。 一个绝对值 1 表示的是 1毫秒 --无疑会使你的集群陷入瘫痪。

4. 修改索引允许最大编译速度

{ 
   "transient": 
    { 
     "script.max_compilations_rate": "100000/1m"}
}

4. 设置返回结果最大偏移量值(Result window is too large, from + size must be less than or equal to: [10000] but was [10010])

5. 索引重建

POST _reindex
{
  "source": {
    "index": "twitter"
  },
  "dest": {
    "index": "new_twitter"
  }
}

# 老的索引指向新的索引, 索引中的数据会进行同步操作



 
调用 reindex 接口,接口将会在 reindex 结束后返回,而接口返回超时只有30秒,如果 reindex 时间过长,建议加上wait_for_completion=false的参数条件,这样 reindex 将直接返回taskId

  

查看异步任务的更新情况:

GET _tasks/hhbzqEj_QMOyttrZD7oOKA:1240872784

6. 索引别名

7. 删除数据

POST mp_accounts/mp_accounts/_delete_by_query

8. 新建索引之后, 定义索引属性

9. 同步一个字段内容到另外一个字段

POST mp_account/mp_account/_update_by_query?wait_for_completion=false
{
  "query":{
    "bool": {
      "must_not": [{
        "exists": {
          "field":"industry_category"
        }
      }
        ]
    }
    
  },
  "script":"ctx._source.industry_category= ctx._source.temp_industry_category;"
}

10. 设置字段分词

{
    "properties": {
          "title": {
             "type": "text",
             "analyzer": "ik_max_word",
             "search_analyzer": "ik_max_word"
          }
    }
}

11. 删除索引中的数据

12. 执行查询语句(使用post方式)

13. 创建索引

{
  "mappings" : {
    "properties" : {
      "name" : {
        "type" : "keyword"
      },
      "age" : {
        "type" : "integer"
      }
    }
  }
}

14. 添加数据

 注意: 这里需要指定索引以及文档类型type

原文地址:https://www.cnblogs.com/xingxia/p/elasticsearch-head.html