Elasticsearch(索引操作

Posted loujiang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch(索引操作相关的知识,希望对你有一定的参考价值。

查看集群状态

GET _cluster/health
http://192.168.1.200:9200/_cluster/health (GET)

{
????"cluster_name":?"cluster-es-node", #节点名称
????"status":?"green", //状态 (三个状态 grenn 标识正长工作 yellow 表示有警告 为分配的 或其他 red 表示不用)
????"timed_out":?false, #是否超时
????"number_of_nodes":?1, #
????"number_of_data_nodes":?1,
????"active_primary_shards":?0, #真时可用的分片
????"active_shards":?0, #激活的分片数
????"relocating_shards":?0,
????"initializing_shards":?0,
????"unassigned_shards":?0, #为分配的分片
????"delayed_unassigned_shards":?0,
????"number_of_pending_tasks":?0,
????"number_of_in_flight_fetch":?0,
????"task_max_waiting_in_queue_millis":?0,
????"active_shards_percent_as_number":?100.0
}
技术图片

索引操作

1.添加索引
put 请求
http://192.168.1.200:9200/index_temp
index_temp(索引名称)
josn参数
{
"settings":{
"index":
{
"number_of_shards":"2", //主 分片数
"number_of_replicas":"0" //备份分片数
}
}
}

返回信息
{
????"acknowledged":?true,
????"shards_acknowledged":?true,
????"index":?"index_temp"
} 代表创建成功

技术图片

技术图片

2.查询索引接口
http://192.168.1.200:9200/index_temp (GET)

返回
{
????"index_temp":?{
????????"aliases":?{}, (别名)
????????"mappings":?{}, (数据类型)
????????"settings":?{
????????????"index":?{
????????????????"creation_date":?"1586669227509", (创建时间
????????????????"number_of_shards":?"2", (主分片)
????????????????"number_of_replicas":?"0", (备份分片
????????????????"uuid":?"oIz2uXxYTSKE4l7J4epsrA", (udid
????????????????"version":?{
????????????????????"created":?"7060299" (版本
????????????????},
????????????????"provided_name":?"index_temp" (索引名称)
????????????}
????????}
????}
}

技术图片

3.删除索引
http://192.168.1.200:9200/index_temp (DELETE)请求
技术图片
再次查看被删除

技术图片

查询所有

技术图片

以上是关于Elasticsearch(索引操作的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch:在 Java 客户端应用中管理索引 - Elastic Stack 8.x

Elasticsearch:在 Java 客户端应用中管理索引 - Elastic Stack 8.x

Elastic Search 基本操作

ElasticSearch常用操作:索引篇

elastic search 索引

怎样查看本地添加的elastic 索引