1.索引的基本操做
1.1新建 Index
1.2刪除 Index
1.3新增記錄
1.4查看記錄
1.5刪除記錄
1.6更新記錄
2.數據查詢
2.1返回全部記錄
2.2全文搜索數據庫
能夠直接向 Elastic 服務器發出 PUT 請求
新建一個名叫 weather 的 Indexjson
$ curl -X PUT 'localhost:9200/weather'
複製代碼
服務器返回一個 JSON 對象,裏面的 acknowledged 字段表示操做成功。
{ "acknowledged":true, "shards_acknowledged":true }服務器
發 DELETE 請求刪除便可markdown
$ curl -X DELETE 'localhost:9200/weather'
複製代碼
PUT請求 指定 id 新增記錄,id 爲字符串便可。curl
$ curl -X PUT 'localhost:9200/accounts/1' -d ' { "user": "張三", "title": "工程師", "desc": "數據庫管理" }'
複製代碼
POST請求則會自動生成隨機字符串 idurl
向/Index/Type/Id發出 GET 請求,參數 pretty=true 表示以易讀的格式返回spa
$ curl 'localhost:9200/accounts/1?pretty=true'
複製代碼
發出 DELETE 請求code
$ curl -X DELETE 'localhost:9200/accounts/1'
複製代碼
使用 PUT 請求,從新發送一次數據,返回的json數據會相應地發生變化:Id 沒變,版本(version)從1變成2,操做類型(result)從created變成updated,created字段變成falseorm
GET 請求 /Index/Type/_search
返回的數據中 默認按 _score 相關度進行排序對象
獨特的查詢語法,要求 GET 請求帶有數據體,默認返回10條數據,可經過 size 字段改變,可經過 from 字段指定其實位置
$ curl 'localhost:9200/accounts/person/_search' -d ' { "query" : { "match" : { "desc" : "軟件" }}, "from": 1, "size": 20 }'
複製代碼