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. Intel® QAT 加速卡之IPSec示例

    Intel QAT 加速卡之IPSec示例 文章目录 Intel QAT 加速卡之IPSec示例 1. QAT处理IPSec入站报文 2. QAT处理IPSec出站报文 3. 组织架构 4. 示例源码 ...

  2. echo -e 命令详解

    echo在php中是输入那么在linux中是不是也是输入呢,当然echo在linux也是输入不过它的用法比php强大多了可以带参数及一些东西,下面我们来看一篇关于linux echo命令介绍及-n.- ...

  3. RMI源码调试

    看RMI漏洞时候,对其漏洞原理并不是很理解,所以简单调试了下源码加强下漏洞理解 由于要调试到RegistryImpl_Stub这种动态类,刚开始用的源码版本是JDK8u141,后来发现源码有些地方进行 ...

  4. Java-SpringBoot整合SpringCloud

    SpringBoot整合SpringCloud 1. SpringCloud特点 SpringCloud专注于为典型的用例和扩展机制提供良好的开箱即用体验,以涵盖其他情况: 分布式/版本化配置 服务注 ...

  5. java版gRPC实战之四:客户端流

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  6. uni-app开发基本知识点

    uni-app: 开始:必须要有一个根view结点. 外部文件引用方式的变化: js要require进来,变成了对象. <script> var util = require('../.. ...

  7. php去除html标签

    function cutstr_html($string){ $string = strip_tags($string); $string = preg_replace(["\t" ...

  8. shell 一些常用命令

    一般自己虚拟机新安装的centos才需要此配置 setenforce 是Linux的selinux防火墙配置命令 执行setenforce 0 表示关闭selinux防火墙. getenforce 查 ...

  9. 制作python程序windows安装包(飞机大战源码)

    本文以飞机大战源码为例: 1.首先使用pyinstaller -w xxx.py打包   -w的意思是不显示命令行:飞机大战源码由多个.py文件以及一些图片,音乐文件组成,我们将main.py打包, ...

  10. 测试工程需要明白的Monkey测试

    App稳定性测试 稳定性测试就是指软件长时间的持续运行,系统版本是否稳定,是否能否持续的为用户提供服务. 指标: 异常的次数 异常的频率 App的稳定性测试如何实施? 首选Monkey Monkey是 ...