es 7.0常用的命令

es 7.0常用的命令

es 7.0中只有索引和文档(document),没有类型(type)了。

  • es 根据条件查询文档:
GET /索引名称/_search

详细的 查询见: https://blog.csdn.net/sinat_32502451/article/details/134367043

  • es 根据_id查询文档:
GET /索引名称/_doc/文档的_id

注意:是 _search返回结果中的 _id, 而不是文档中的字段id。

  • es新建索引:

格式:

PUT /索引名称
{
    "mappings":
	{
		"properties":{
			"字段名称":{
				"type":"字段类型"
			}
		}
	}
}

PUT 加索引名称 ,比如以下的 PUT /book_2023_09

type 表示字段类型。id、order_no 这些是字段名。

示例:

PUT /book_2023_09
{
    "mappings":
	{
		"properties":{
			"id":{
				"type":"long"
			},
			"order_no":{
				"type":"text"
			},
			"name":{
				"type":"keyword"
			},
			"create_date":{
				"type":"date"
			}

		}
	}
}
  • es 查询索引的字段结构/数据结构
GET /索引名称/_mapping
  • es 查询索引下面文档数量
GET /索引名称/_count
  • es 添加/更新别名:
PUT /索引名称/_alias/别名名称
  • es 查询别名:
GET /索引名称/_alias
  • es 新增文档:
POST /索引名称/_doc

示例:

POST /book_2020_09/_doc
{
  "name": "wu",
  "create_date": "2020-10-24",
  "order_no": "082313sfsd1",
  "id": 10823131
}

posted on   乐之者v  阅读(117)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示