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 ...
随机推荐
- aes加解密前后端-后台
一.web.xml: <filter> <filter-name>fastLoginFilter</filter-name> <filter-class> ...
- study day2
study day2 windows 常用快捷键 CTRL C:复制 CTRL V:粘贴 CTRL A:全选 CTRL X:剪切 CTRL S:保存 CTRL Z:撤销 alt f4:关闭窗口 shi ...
- Docker入门系列之二:Docker术语
原文作者:Jeff Hale 原文地址:https://towardsdatascience.com/learn-enough-docker-to-be-useful-1c40ea269fa8 翻译: ...
- linux错误: locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
命令 locate my.cnf 产生以上错误 此时执行 # updatedb 更新下数据库即可
- php发送邮件方法-亲测可用,email.class.php过期解决办法
php虽然提供了mail()函数,但并不好用,而PHPMailer是一个不错的邮件发送工具,使用起来也是非常简单!使用PHPMailer发送邮件: <?php header("cont ...
- ecshop增加调用字段问题汇总
一.ecshop文章列表页调用缩略图.网页描述等 打开includes/lib_article.php文件,大约在69行 添加 $arr[$article_id]['description'] = $ ...
- Shell系列(33) - 多分支if语句简介及计算器例子
多分支if条件语句 if [ 条件判断式1 ] then 当条件判断式1成立时,执行程序1 elif [ 条件判断式2 ] then 当条件判断式2成立时,执行程序2 ...省略更多条件... els ...
- windows系统升级python
卸载python最干净的办法 https://blog.csdn.net/ic_zswdbk/article/details/88315779?utm_medium=distribute.pc_rel ...
- 深入剖析 Laravel 服务容器
https://cloud.tencent.com/developer/article/1340400
- P4929-[模板]舞蹈链(DLX)
正题 题目链接:https://www.luogu.com.cn/problem/P4929 题目大意 \(n*m\)的矩形有\(0/1\),要求选出若干行使得每一列有且仅有一个\(1\). 解题思路 ...