elasticsearch的索引操作
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的索引操作的更多相关文章
- ElasticSearch+Kibana 索引操作
ElasticSearch+Kibana 索引操作 一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引 ...
- elasticsearch的索引操作和文档操作总结
参考文档:https://es.xiaoleilu.com/010_Intro/00_README.html 一.索引操作 1.查看当前节点的所有的index 查看当前节点的所有的index [roo ...
- ElasticSearch+Kibana 索引操作( 附源码)
一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elastics ...
- elasticsearch java 索引操作
1.添加maven依赖 <dependency> <groupId>org.elasticsearch</groupId> <artifactId>el ...
- Es图形化软件使用之ElasticSearch-head、Kibana,Elasticsearch之-倒排索引操作、映射管理、文档增删改查
今日内容概要 ElasticSearch之-ElasticSearch-head ElasticSearch之-安装Kibana Elasticsearch之-倒排索引 Elasticsearch之- ...
- ElasticSearch 基本概念 and 索引操作 and 文档操作 and 批量操作 and 结构化查询 and 过滤查询
基本概念 索引: 类似于MySQL的表.索引的结构为全文搜索作准备,不存储原始的数据. 索引可以做分布式.每一个索引有一个或者多个分片 shard.每一个分片可以有多个副本 replica. 文档: ...
- Elasticsearch——多索引的使用
在Elasticsearch中,一般的查询都支持多索引. 只有文档API或者别名等不支持多索引操作,因此本篇就翻译一下多索引相关的内容. 首先,先插入几条数据: $ curl -XPOST local ...
- Elasticsearch-PHP 索引操作(转)
索引操作 本节通过客户端来介绍一下索引API的各种操作.索引操作包含任何管理索引本身(例如,创建索引,删除索引,更改映射等等). 我们通过一些常见的操作的代码片段来介绍,然后在表格中列出剩下的方法.R ...
- Elasticsearch多索引
在Elasticsearch中,一般的查询都支持多索引.只有文档API或者别名API等不支持多索引操作,因此本篇就翻译一下多索引相关的内容. 首先,先插入几条数据: $ curl -XPOST lo ...
随机推荐
- python3 爬虫五大模块之四:网页解析器
Python的爬虫框架主要可以分为以下五个部分: 爬虫调度器:用于各个模块之间的通信,可以理解为爬虫的入口与核心(main函数),爬虫的执行策略在此模块进行定义: URL管理器:负责URL的管理,包括 ...
- Asp.net MVC Vue Axios无刷新请求数据和响应数据
Model层Region.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; ...
- jquery实现强制刷新
$('iframe.active').attr('src', $('iframe.active').attr('src'));
- python库--tensorflow--数学函数
官方API(需FQ) 中文API 方法 返回值类型 参数 说明 算数运算符 .add() Tensor x, y, name=N 加法(若x,y都为tensor, 数据类型需一致, 以下所有x,y都如 ...
- 三剑客之sed编辑器 基操
目录: 一.sed编辑器 二.打印内容 三.使用地址 四.删除行 五.替换 六.插入 一.sed编辑器 sed是一种流编辑器,流编辑器会在编辑器处理数据之前基于预先提供的一组规则来编辑数据流. sed ...
- HTTP证书申请,设置应用程序服务器使用HTTPS
HTTP证书申请,设置应用程序服务器使用HTTPS https://certs.godaddy.com/repository/ 根证书和中级证书下载地址(godaddy) ######Godaddy购 ...
- 2020ICPC沈阳站C题 Mean Streets of Gadgetzan
大致题意 原题链接 翻译 \(有n个逻辑变量 请你分别对它们赋值 使其满足m个命题\) \(命题有四种格式:\) 单独数字x 表示第x个逻辑变量为真 ! + 数字x 表示第x个逻辑变量为假 若干个数字 ...
- Git - 命令行 常用
一.合并其他分支的commit(A分支中的commit合并至B分支) 切换到A分支,查询commit历史命令行 : $ git log 复制要合并的commit id (如:663802dfb121e ...
- windows 中cmd一些特殊命令
chcp 65001 就是换成UTF-8代码页 chcp 936 可以换回默认的GBK chcp 437 是美国英语 shutdown -s -t 60 60秒后关机 shutdown /a ...
- php nginx 路径批量配置
* 假设 E:\upload 作为图片上传的位置 nginx 做web服务 * 创建文件conf.php 放到这个目录下 <?php function handleDir($it, &$ ...