留意,如不雅没有先创建 Index(这个例子是 accounts ),直接履行膳绫擎的敕令,Elastic 也不会报错,而是直接生成指定的 Index。所以,打字的时刻要当心,不要写错 Index 的名称。
5.2 查看记录
向 /Index/Type/Id 发出 GET 请求,就可以查看这笔记录。
- $ curl 'localhost:9200/accounts/person/1?pretty=true'
膳绫擎代码请求查看 /accounts/person/1 这笔记录,URL 的参数 pretty=true 表示以易读的格局返回。
返回的数据中, found 字段表示萌芽成功, _source 字段返回原始记录。
如不雅 Id 不精确,就查不到数据, found 字段就是 false 。
- $ curl 'localhost:9200/weather/beijing/abc?pretty=true'
- {
- "_index" : "weather",
- "_type" : "beijing",
- "_id" : "abc",
- "found" : false
- }
5.3 删除记录
- $ curl -X DELETE 'localhost:9200/accounts/person/1'
这里先不要删除这笔记录,后面还要用到。
5.4 更新记录
更新记录就是应用 PUT 请求,从新发送一次数据。
- $ curl -X PUT 'localhost:9200/accounts/person/1' -d '
- {
- "user" : "张三",
- "title" : "工程师",
- "desc" : "数据库治理,软件开辟"
- }'
- {
- "_index":"accounts",
- "_type":"person",
- "_id":"1",
- "_version":2,
- "result":"updated",
- "_shards":{"total"
推荐阅读
【51CTO晃荡】8.26 带你深度懂得清华大年夜学、搜狗基于算法的IT运维实践与摸索 看上去已经变得模糊的机会终于光降。来自一线的商户感触感染尤其明显:「我们很早就上线了本身的小法度榜>>>详细阅读
地址:http://www.17bianji.com/lsqh/36787.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示