一齐苛、格式
http://192.168.0.1:9200/<index>/<type>/[<id>]
- index:代表數(shù)據(jù)庫(kù)
- type:對(duì)應(yīng)表
二引镊、增
//可以使用put,也可以使用post
curl -XPUT "http://192.168.0.1:9200/store/books/1" -d '{
"title":"Elastticsearch: The Definitive Guide",
"name": {
"first": "jason",
"last": "lai"
},
"publish_date":"2015-02-06",
"price":"88.88"
}'
- 返回如下信息
{"_index":"store","_type":"books","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}
三指厌、刪
curl -XDELETE 'http://192.168.0.1:9200/store/books/1'
四刊愚、改(將價(jià)格字段由原來(lái)的88.88改為99.99)
//可以使用put,也可以使用post
curl -XPUT "http://192.168.0.1:9200/store/books/1" -d '{
"title":"Elastticsearch: The Definitive Guide",
"name": {
"first": "jason",
"last": "lai"
},
"publish_date":"2015-02-06",
"price":"99.99"
}'
五踩验、查
- 使用curl查詢鸥诽,也可以是用瀏覽器查詢
curl -XGET "http://192.168.0.1:9200/store/books/1"
- 返回如下信息
{"_index":"store","_type":"books","_id":"1","_version":1,"found":true,"_source":{
"title":"Elastticsearch: The Definitive Guide",
"name": {
"first": "jason",
"last": "lai"
},
"publish_date":"2015-02-06",
"price":"88.88"
}
}
- 可以指定字段查詢(_source代表返回字段)
curl -XGET "http://192.168.0.1:9200/store/books/1?_source=title,name"
返回如下信息
{"_index":"store","_type":"books","_id":"1","_version":2,"found":true,"_source":{"name":{"first":"Vineeth","last":"Mohan"},"title":"Elastticsearch Blueprints"}}