我是靠谱客的博主 兴奋小蘑菇,这篇文章主要介绍elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在,现在分享给大家,希望可以做个参考。

elasticsearch如何新建索引+查询索引+删除索引+判断索引是否存在

1.es新建索引,并定义好索引类型

  • 输入
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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" } } } }
  • 输出
复制代码
1
2
3
4
5
6
{ "acknowledged" : true, "shards_acknowledged" : true, "index" : "log" }

2.查看之前定义好的索引

  • 输入
复制代码
1
2
GET /log/_mapping
  • 输出
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ "log" : { "mappings" : { "properties" : { "accessTime" : { "type" : "text" }, "id" : { "type" : "long" }, "param" : { "type" : "text" }, "result" : { "type" : "text" }, "url" : { "type" : "text" }, "userId" : { "type" : "long" } } } } }

3.删除之前定好的索引

  • 输入
复制代码
1
2
DELETE /log
  • 输出
复制代码
1
2
3
4
{ "acknowledged" : true }

4.判断索引是否存在

  • 输入
复制代码
1
2
HEAD /log
  • 输出

如果存在

复制代码
1
2
200 - OK

如果不存在

复制代码
1
2
{"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如何新建索引+查询索引+删除索引+判断索引是否存在内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(61)

评论列表共有 0 条评论

立即
投稿
返回
顶部