本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

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

发布于2021-06-06 17:13     阅读(971)     评论(0)     点赞(4)     收藏(0)


index

创建index

获取index详情

获取所有es中的index

删除index

document

创建document

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

指定id创建document

获取某个document的信息

获取所有document

删除指定的document

全量修改指定document

修改指定document的某个属性

postman导出文件内容

  1. {
  2. "info": {
  3. "_postman_id": "96f242ab-9ed9-4540-9fde-9feec40b1791",
  4. "name": "ElasticSearch",
  5. "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  6. },
  7. "item": [
  8. {
  9. "name": "base option",
  10. "item": [
  11. {
  12. "name": "index options",
  13. "item": [
  14. {
  15. "name": "get all index",
  16. "request": {
  17. "method": "GET",
  18. "header": [],
  19. "url": {
  20. "raw": "http://127.0.0.1:9200/_cat/indices?v",
  21. "protocol": "http",
  22. "host": [
  23. "127",
  24. "0",
  25. "0",
  26. "1"
  27. ],
  28. "port": "9200",
  29. "path": [
  30. "_cat",
  31. "indices"
  32. ],
  33. "query": [
  34. {
  35. "key": "v",
  36. "value": null
  37. }
  38. ]
  39. }
  40. },
  41. "response": []
  42. },
  43. {
  44. "name": "delete index",
  45. "request": {
  46. "method": "DELETE",
  47. "header": [],
  48. "url": {
  49. "raw": "http://127.0.0.1:9200/shopping",
  50. "protocol": "http",
  51. "host": [
  52. "127",
  53. "0",
  54. "0",
  55. "1"
  56. ],
  57. "port": "9200",
  58. "path": [
  59. "shopping"
  60. ]
  61. }
  62. },
  63. "response": []
  64. },
  65. {
  66. "name": "create index",
  67. "request": {
  68. "method": "PUT",
  69. "header": [],
  70. "url": {
  71. "raw": "http://127.0.0.1:9200/shopping",
  72. "protocol": "http",
  73. "host": [
  74. "127",
  75. "0",
  76. "0",
  77. "1"
  78. ],
  79. "port": "9200",
  80. "path": [
  81. "shopping"
  82. ]
  83. }
  84. },
  85. "response": []
  86. },
  87. {
  88. "name": "get index",
  89. "request": {
  90. "method": "GET",
  91. "header": [],
  92. "url": {
  93. "raw": "http://127.0.0.1:9200/shopping",
  94. "protocol": "http",
  95. "host": [
  96. "127",
  97. "0",
  98. "0",
  99. "1"
  100. ],
  101. "port": "9200",
  102. "path": [
  103. "shopping"
  104. ]
  105. }
  106. },
  107. "response": []
  108. }
  109. ]
  110. },
  111. {
  112. "name": "document options",
  113. "item": [
  114. {
  115. "name": "create document",
  116. "protocolProfileBehavior": {
  117. "disabledSystemHeaders": {}
  118. },
  119. "request": {
  120. "method": "POST",
  121. "header": [],
  122. "body": {
  123. "mode": "raw",
  124. "raw": "{\r\n \"title\" : \"小米10\",\r\n \"brand\" : \"小米\",\r\n \"price\" : 4000\r\n}",
  125. "options": {
  126. "raw": {
  127. "language": "json"
  128. }
  129. }
  130. },
  131. "url": {
  132. "raw": "http://127.0.0.1:9200/shopping/_doc",
  133. "protocol": "http",
  134. "host": [
  135. "127",
  136. "0",
  137. "0",
  138. "1"
  139. ],
  140. "port": "9200",
  141. "path": [
  142. "shopping",
  143. "_doc"
  144. ]
  145. }
  146. },
  147. "response": []
  148. },
  149. {
  150. "name": "get document info",
  151. "request": {
  152. "method": "GET",
  153. "header": [],
  154. "url": {
  155. "raw": "http://127.0.0.1:9200/shopping/_doc/7pbvzHkBYAUbzfBKmCoR",
  156. "protocol": "http",
  157. "host": [
  158. "127",
  159. "0",
  160. "0",
  161. "1"
  162. ],
  163. "port": "9200",
  164. "path": [
  165. "shopping",
  166. "_doc",
  167. "7pbvzHkBYAUbzfBKmCoR"
  168. ]
  169. }
  170. },
  171. "response": []
  172. },
  173. {
  174. "name": "get all document",
  175. "request": {
  176. "method": "GET",
  177. "header": [],
  178. "url": {
  179. "raw": "http://127.0.0.1:9200/shopping/_search",
  180. "protocol": "http",
  181. "host": [
  182. "127",
  183. "0",
  184. "0",
  185. "1"
  186. ],
  187. "port": "9200",
  188. "path": [
  189. "shopping",
  190. "_search"
  191. ]
  192. }
  193. },
  194. "response": []
  195. },
  196. {
  197. "name": "update document all content",
  198. "request": {
  199. "method": "PUT",
  200. "header": [],
  201. "body": {
  202. "mode": "raw",
  203. "raw": "{\r\n \"title\" : \"小米11\",\r\n \"brand\" : \"小米\",\r\n \"price\" : 4001\r\n}",
  204. "options": {
  205. "raw": {
  206. "language": "json"
  207. }
  208. }
  209. },
  210. "url": {
  211. "raw": "http://127.0.0.1:9200/shopping/_doc/7pbvzHkBYAUbzfBKmCoR",
  212. "protocol": "http",
  213. "host": [
  214. "127",
  215. "0",
  216. "0",
  217. "1"
  218. ],
  219. "port": "9200",
  220. "path": [
  221. "shopping",
  222. "_doc",
  223. "7pbvzHkBYAUbzfBKmCoR"
  224. ]
  225. }
  226. },
  227. "response": []
  228. },
  229. {
  230. "name": "update document",
  231. "request": {
  232. "method": "POST",
  233. "header": [],
  234. "body": {
  235. "mode": "raw",
  236. "raw": "{\r\n \"doc\" : {\r\n \"title\" : \"小米30\"\r\n }\r\n}",
  237. "options": {
  238. "raw": {
  239. "language": "json"
  240. }
  241. }
  242. },
  243. "url": {
  244. "raw": "http://127.0.0.1:9200/shopping/_update/7pbvzHkBYAUbzfBKmCoR",
  245. "protocol": "http",
  246. "host": [
  247. "127",
  248. "0",
  249. "0",
  250. "1"
  251. ],
  252. "port": "9200",
  253. "path": [
  254. "shopping",
  255. "_update",
  256. "7pbvzHkBYAUbzfBKmCoR"
  257. ]
  258. }
  259. },
  260. "response": []
  261. },
  262. {
  263. "name": "delete document",
  264. "request": {
  265. "method": "DELETE",
  266. "header": [],
  267. "url": {
  268. "raw": "http://127.0.0.1:9200/shopping/_doc/7ZbvzHkBYAUbzfBKhCoL",
  269. "protocol": "http",
  270. "host": [
  271. "127",
  272. "0",
  273. "0",
  274. "1"
  275. ],
  276. "port": "9200",
  277. "path": [
  278. "shopping",
  279. "_doc",
  280. "7ZbvzHkBYAUbzfBKhCoL"
  281. ]
  282. }
  283. },
  284. "response": []
  285. },
  286. {
  287. "name": "create document with id",
  288. "request": {
  289. "method": "POST",
  290. "header": [],
  291. "body": {
  292. "mode": "raw",
  293. "raw": "{\r\n \"title\" : \"小米10\",\r\n \"brand\" : \"小米\",\r\n \"price\" : 4000\r\n}",
  294. "options": {
  295. "raw": {
  296. "language": "json"
  297. }
  298. }
  299. },
  300. "url": {
  301. "raw": "http://127.0.0.1:9200/shopping/_doc/123abc",
  302. "protocol": "http",
  303. "host": [
  304. "127",
  305. "0",
  306. "0",
  307. "1"
  308. ],
  309. "port": "9200",
  310. "path": [
  311. "shopping",
  312. "_doc",
  313. "123abc"
  314. ]
  315. }
  316. },
  317. "response": []
  318. }
  319. ]
  320. }
  321. ]
  322. }
  323. ]
  324. }

 



所属网站分类: 技术文章 > 博客

作者:门路弄土了吗

链接:http://www.phpheidong.com/blog/article/88197/babbe18c8a61e7316fc5/

来源:php黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

4 0
收藏该文
已收藏

评论内容:(最多支持255个字符)