我是靠谱客的博主 兴奋小蘑菇,最近开发中收集的这篇文章主要介绍elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在
1.es新建索引,并定义好索引类型
- 输入
PUT /log
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"id": {
"type": "long"
},
"url": {
"type": "text"
},
"accessTime": {
"type": "text"
},
"userId": {
"type": "long"
},
"param": {
"type": "text"
},
"result": {
"type": "text"
}
}
}
}
- 输出
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "log"
}
2.查看之前定义好的索引
- 输入
GET /log/_mapping
- 输出
{
"log" : {
"mappings" : {
"properties" : {
"accessTime" : {
"type" : "text"
},
"id" : {
"type" : "long"
},
"param" : {
"type" : "text"
},
"result" : {
"type" : "text"
},
"url" : {
"type" : "text"
},
"userId" : {
"type" : "long"
}
}
}
}
}
3.删除之前定好的索引
- 输入
DELETE /log
- 输出
{
"acknowledged" : true
}
4.判断索引是否存在
- 输入
HEAD /log
- 输出
如果存在
200 - OK
如果不存在
{"statusCode":404,"error":"Not Found","message":"404 - Not Found"}
二.致谢
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html
最后
以上就是兴奋小蘑菇为你收集整理的elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在的全部内容,希望文章能够帮你解决elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复