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 ...
随机推荐
- 什么是 baseline 和 benchmark
baseline 一个算法被称为 baseline 算法说明这个比目前这个算法还差的已经不能接受了,方法有革命性的创新点可以挖掘,且存在巨大提升空间和超越benchmark的潜力,只是由于发展初期导致 ...
- 解决vscode可以编译通过c++项目,但头文件有红色波浪线的问题
解决vscode可以编译通过c++项目,但头文件有红色波浪线的问题 一.问题描述 我是在Ubuntu 16.04的环境下,用vscode写代码的,一般不使用vscode自带的编译环境,而是用cmake ...
- Vue组件封装之无限滚动列表
无限滚动列表:分为单步滚动和循环滚动两种方式 <template> <div class="box" :style="{width:widthX,hei ...
- mysql中varchar类型和datetime类型字段进行比较
我是在mysql5.7版本进行比较 表a的字段order_no和表iwebshop_tmp的字段order_no一样 需要更新iwebshop_member_order表的datetime类型expi ...
- 一文让你快速入门pytest框架
pytest是什么 官方文档描述: pytest is a framework that makes building simple and scalable tests easy. Tests ar ...
- vm 将宿主机文件夹 映射至 虚拟机
一.关于centos如何安装(自行百度) 二.设置共享文件夹 添加共享文件夹(关闭虚拟机时操作) 虚拟机->设置->选项->共享文件夹 三.安装vm-tools (请用root用户执 ...
- CF803G-Periodic RMQ Problem【离散化,线段树,ST表】
正题 题目链接:https://www.luogu.com.cn/problem/CF803G 题目大意 一个长度为\(n\)的序列\(a\)复制\(k\)份连接,要求支持 区间赋值 区间查询最小值 ...
- python接口自动化--json解析神器jsonpath
前言 做接口测试的时候,大部分情况下返回的是json数据,我们需要对返回的json断言. 当返回的数据量比较大,并且嵌套的层级很深的时候,很多小伙伴不会取值,往往在返回结果取值上浪费很多时间.一直在寻 ...
- Python代码阅读(第8篇):列表元素逻辑判断
Python 代码阅读合集介绍:为什么不推荐Python初学者直接看项目源码 本篇阅读的三份代码的功能分别是判断列表中的元素是否都符合给定的条件:判断列表中是否存在符合给定的条件的元素:以及判断列表中 ...
- ldirectord
试想,LVS作为前端负载均衡设备,当后端服务器宕机时,LVS还会把用户请求发送到该服务器上,这对用户体验来说是极其糟糕的,因为用户的请求无法得到处理.那么是否有一种机制,能保证后端服务器的是否正常?或 ...