1、创建索引(test_index)

curl -XPUT "http://192.168.99.1:9200/test_index"

2、创建索引,指定分片和副本的数量

curl -XPUT "http://192.168.99.1:9200/test_index" -d'
{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
}
}'

3、创建索引(test_index)、创建类型(product)、指定mapping的数据

curl -XPUT "http://192.168.99.1:9200/test_index" -d'
{
"mappings": {
"product" : {
"properties": {
"id" : {
"type": "text",
"index": "not_analyzed"
},
"userName" : {
"type": "text",
"index": "analyzed"
}
}
}
}
}'

4、已经存在的类型的mapping中的字段的值不可修改,但是可以新增

注意:es7之后_mapping后面不可指定type,es7之后一个索引只有一个type(_doc)

curl -XPOST "http://192.168.99.1:9200/test_index/_mapping/product" -d'
{
"properties": {
"price" : {
"type": "long"
}
}
}'

5、在已经存在的索引下新增加一个类型

注意:es7之后_mapping后面不可指定type,es7之后一个索引只有一个type(_doc)

curl -XPOST "http://192.168.99.1:9200/test_index/_mapping/add_new_type" -d'
{
"properties": {
"field01" : {
"type": "text"
}
}
}'

6、关闭索引(不可读也不可写)

curl -XPOST "http://192.168.99.1:9200/test_index/_close"

冻结索引(可以读但是不可以写) 解冻(_unfreeze)

curl -XPOST "http://192.168.99.1:9200/test_index/_freeze"

7、打开索引

curl -XPOST "http://192.168.99.1:9200/test_index/_open"

8、获取索引下的信息

curl -XGET "http://192.168.99.1:9200/test_index"

9、查看索引的统计信息

curl -XGET "http://192.168.99.1:9200/test_index/_stats"

10、获取索引的mappings

curl -XGET "http://192.168.99.1:9200/test_index/_mappings"

11、删除索引

curl -XDELETE "http://192.168.99.1:9200/test_index"

12、取消es的自动创建索引,修改es的配置文件

action.auto_create_index: false 

13、创建索引的别名  (_alias用于单个操作,而_aliases则是用于多个操作,保持原子性)

方式一:


     方式二:

curl -XPUT "http://192.168.99.1:9200/test_index/_alias/alias_new_index"

14、修改索引别名(先删除后增加)

curl -XPOST "http://192.168.99.1:9200/_aliases" -d'
{
"actions": [
{
"remove": {
"index": "test_index","alias": "alias_index"
}
},
{
"add": {
"index": "test_index","alias": "alias_new_index"
}
}
]
}'

15、删除索引别名

方式一:

curl -XPOST "http://192.168.99.1:9200/_aliases" -d'
{
"actions": [
{
"remove": {
"index": "test_index","alias": "alias_new_index"
}
}
]
}'

方式二:(删除索引以test开始并且别名是alias_new_index的这个别名)

curl -XDELETE "http://192.168.99.1:9200/test*/_aliases/alias_new_index"

16、查询test_index索引下所有的别名

curl -XGET "http://192.168.99.1:9200/test_index/_alias/*"

17、查询别名alias_new_index关联了那些索引

curl -XGET "http://192.168.99.1:9200/_alias/alias_new_index"

elasticsearch的索引操作的更多相关文章

  1. ElasticSearch+Kibana 索引操作

    ElasticSearch+Kibana 索引操作 一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引 ...

  2. elasticsearch的索引操作和文档操作总结

    参考文档:https://es.xiaoleilu.com/010_Intro/00_README.html 一.索引操作 1.查看当前节点的所有的index 查看当前节点的所有的index [roo ...

  3. ElasticSearch+Kibana 索引操作( 附源码)

    一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elastics ...

  4. elasticsearch java 索引操作

    1.添加maven依赖 <dependency> <groupId>org.elasticsearch</groupId> <artifactId>el ...

  5. Es图形化软件使用之ElasticSearch-head、Kibana,Elasticsearch之-倒排索引操作、映射管理、文档增删改查

    今日内容概要 ElasticSearch之-ElasticSearch-head ElasticSearch之-安装Kibana Elasticsearch之-倒排索引 Elasticsearch之- ...

  6. ElasticSearch 基本概念 and 索引操作 and 文档操作 and 批量操作 and 结构化查询 and 过滤查询

    基本概念 索引: 类似于MySQL的表.索引的结构为全文搜索作准备,不存储原始的数据. 索引可以做分布式.每一个索引有一个或者多个分片 shard.每一个分片可以有多个副本 replica. 文档: ...

  7. Elasticsearch——多索引的使用

    在Elasticsearch中,一般的查询都支持多索引. 只有文档API或者别名等不支持多索引操作,因此本篇就翻译一下多索引相关的内容. 首先,先插入几条数据: $ curl -XPOST local ...

  8. Elasticsearch-PHP 索引操作(转)

    索引操作 本节通过客户端来介绍一下索引API的各种操作.索引操作包含任何管理索引本身(例如,创建索引,删除索引,更改映射等等). 我们通过一些常见的操作的代码片段来介绍,然后在表格中列出剩下的方法.R ...

  9. Elasticsearch多索引

     在Elasticsearch中,一般的查询都支持多索引.只有文档API或者别名API等不支持多索引操作,因此本篇就翻译一下多索引相关的内容. 首先,先插入几条数据: $ curl -XPOST lo ...

随机推荐

  1. 修改Typora的代码以支持文件夹和文件混合排序

    用Markdown文件写笔记,用文件夹做分类,整个笔记文档项目构成了一个树形结构.笔记文章之间.文章与分类之间经常有特定的先后顺序,于是就在文件名前面加上数字前缀来控制排序.但是,Windows的文件 ...

  2. 记录一次sql注入绕过

    目标:http://www.xxxxx.net/temp.asp?ID=10359 通过 and 1=1 and 1=2 测试发现存在拦截 首先想到 and 空格 = 可能存在触发规则 一般遇到这种情 ...

  3. awk工作流程

    awk 工作过程:先执行BEGIN模块,再跟文本交互,最后执行END模块.也就是说BEGIN/END模块,这俩是单独操作跟文本是同一级,但执行有优先级,BEGIN模块>文本>END模块 行 ...

  4. go build 与go install

    相同点都能生成可执行文件 不同点go build 不能生成包文件, go install 可以生成包文件go build 生成可执行文件在当前目录下, go install 生成可执行文件在bin目录 ...

  5. 获取docker镜像的tag列表

    已nginx为例 命令如下 wget -q https://registry.hub.docker.com/v1/repositories/nginx/tags -O - | sed -e 's/[] ...

  6. scrum项目冲刺_day11 第一阶段总结

    "智能垃圾分类APP"第一阶段总结 总任务: 一.appUI页面(已完成) 二.首页功能: 1.图像识别功能(已完成) 2.语音识别功能(已完成) 3.垃圾搜索功能(基本完成) 4 ...

  7. CentOS8部署tftp

    tftp:简单文本传输协议,而ftp:文本传输协议.可以把tftp看成是ftp的精简版.tftp用于免登录传输小文件,tftp服务端监听在udp协议的69端口tftp简单的工作原理: tftp服务端与 ...

  8. webpack learn4-1配置css单独分离打包

    1 先安装extract-text-webpack-plugin npm i extract-text-webpack-plugin 2 配置webpack.config.js

  9. css宽度+字体+颜色+边框+文本+光标+伪类选择器

    常用属性: width:宽 height:高 min-width:最小宽度 :可以设置如果宽度变小了,有个滑动效果(常常在我们布局的过程中需要去设置) min-height;最小高度 max-widt ...

  10. 解决Windows 游戏 错误代码 1170000

    安装"Xbox标识提供程序" 下载地址:https://www.microsoft.com/store/apps/9wzdncrd1hkw