Rest风格---ElasticSearch
生活随笔
收集整理的這篇文章主要介紹了
Rest风格---ElasticSearch
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Rest風格
5.1 簡介
RESTful是一種架構的規范與約束、原則,符合這種規范的架構就是RESTful架構。
操作
| PUT | localhost:9100/索引名稱/類型名稱/文檔id | 創建文檔(指定id) |
| POST | localhost:9100/索引名稱/類型名稱 | 創建文檔(隨機id) |
| POST | localhost:9100/索引名稱/文檔類型/文檔id/_update | 修改文檔 |
| DELETE | localhost:9100/索引名稱/文檔類型/文檔id | 刪除文檔 |
| GET | localhost:9100/索引名稱/文檔類型/文檔id | 查詢文檔通過文檔id |
| POST | localhost:9100/索引名稱/文檔類型/_search | 查詢所有文檔 |
5.2 測試
- 1、創建一個索引PUT /索引名/類型名/id
- 默認是_doc
數據類型
- 字符串 text, keyword
- 數據類型 long, integer,short,byte,double,float,half_float,scaled_float
- 日期 date
- 布爾 boolean
- 二進制 binary
創建規則
PUT /test2 {"mappings": {"properties": {"name": {"type": "text"},"age": {"type": "long"},"birthday": {"type": "date"}}} }輸出:
{"acknowledged" : true,"shards_acknowledged" : true,"index" : "test2" }如果不指定具體類型,es會默認配置類型
查看索引
GET test2
-
查看es信息
get _cat/
修改
1. 之前的辦法:直接put2. 現在的辦法: POST /test1/_doc/1/_update{ "doc": {"name": "龐世宗"}}刪除索引
DELETE test1
總結
以上是生活随笔為你收集整理的Rest风格---ElasticSearch的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: EasyExcel(笔记)
- 下一篇: 关于文档的基本操作---ElasticS