ElasticSearch index&document基本操作,附带postman导出文件

index

创建index

获取index详情

获取所有es中的index

删除index

document

创建document

需要注意的是,post请求创建document的时候,是不满足幂等性的,每一次请求都是创建一个新的document。在没有明确指定id的情况下,每一个创建的document都会自动分配一个唯一id

指定id创建document

获取某个document的信息

获取所有document

删除指定的document

全量修改指定document

修改指定document的某个属性

postman导出文件内容

{
	"info": {
		"_postman_id": "96f242ab-9ed9-4540-9fde-9feec40b1791",
		"name": "ElasticSearch",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "base option",
			"item": [
				{
					"name": "index options",
					"item": [
						{
							"name": "get all index",
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/_cat/indices?v",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"_cat",
										"indices"
									],
									"query": [
										{
											"key": "v",
											"value": null
										}
									]
								}
							},
							"response": []
						},
						{
							"name": "delete index",
							"request": {
								"method": "DELETE",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/shopping",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping"
									]
								}
							},
							"response": []
						},
						{
							"name": "create index",
							"request": {
								"method": "PUT",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/shopping",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping"
									]
								}
							},
							"response": []
						},
						{
							"name": "get index",
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/shopping",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping"
									]
								}
							},
							"response": []
						}
					]
				},
				{
					"name": "document options",
					"item": [
						{
							"name": "create document",
							"protocolProfileBehavior": {
								"disabledSystemHeaders": {}
							},
							"request": {
								"method": "POST",
								"header": [],
								"body": {
									"mode": "raw",
									"raw": "{\r\n    \"title\" : \"小米10\",\r\n    \"brand\" : \"小米\",\r\n    \"price\" : 4000\r\n}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_doc",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_doc"
									]
								}
							},
							"response": []
						},
						{
							"name": "get document info",
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_doc/7pbvzHkBYAUbzfBKmCoR",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_doc",
										"7pbvzHkBYAUbzfBKmCoR"
									]
								}
							},
							"response": []
						},
						{
							"name": "get all document",
							"request": {
								"method": "GET",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_search",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_search"
									]
								}
							},
							"response": []
						},
						{
							"name": "update document all content",
							"request": {
								"method": "PUT",
								"header": [],
								"body": {
									"mode": "raw",
									"raw": "{\r\n    \"title\" : \"小米11\",\r\n    \"brand\" : \"小米\",\r\n    \"price\" : 4001\r\n}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_doc/7pbvzHkBYAUbzfBKmCoR",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_doc",
										"7pbvzHkBYAUbzfBKmCoR"
									]
								}
							},
							"response": []
						},
						{
							"name": "update document",
							"request": {
								"method": "POST",
								"header": [],
								"body": {
									"mode": "raw",
									"raw": "{\r\n    \"doc\" : {\r\n        \"title\" : \"小米30\"\r\n            }\r\n}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_update/7pbvzHkBYAUbzfBKmCoR",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_update",
										"7pbvzHkBYAUbzfBKmCoR"
									]
								}
							},
							"response": []
						},
						{
							"name": "delete document",
							"request": {
								"method": "DELETE",
								"header": [],
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_doc/7ZbvzHkBYAUbzfBKhCoL",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_doc",
										"7ZbvzHkBYAUbzfBKhCoL"
									]
								}
							},
							"response": []
						},
						{
							"name": "create document with id",
							"request": {
								"method": "POST",
								"header": [],
								"body": {
									"mode": "raw",
									"raw": "{\r\n    \"title\" : \"小米10\",\r\n    \"brand\" : \"小米\",\r\n    \"price\" : 4000\r\n}",
									"options": {
										"raw": {
											"language": "json"
										}
									}
								},
								"url": {
									"raw": "http://127.0.0.1:9200/shopping/_doc/123abc",
									"protocol": "http",
									"host": [
										"127",
										"0",
										"0",
										"1"
									],
									"port": "9200",
									"path": [
										"shopping",
										"_doc",
										"123abc"
									]
								}
							},
							"response": []
						}
					]
				}
			]
		}
	]
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值