1、增加记录

例如1:向指定的 /Index/Type 发送 PUT 请求,就可以在 Index 里面新增一条记录。比如,向/accounts/person发送请求,就可以新增一条人员记录。

curl -X POST  'localhost:9200/accounts/person/2' -d '{"user":"张三","title": "工程师","desc":"系统管理"}'

  系统提示如下错误:

{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}

  

需要制定插入数据格式:如下

curl -H "Content-Type: application/json" -X POST  'localhost:9200/accounts/person/2' -d '{"user":"张三","title": "工程师","desc":"系统管理"}'

系统提示:

{"_index":"accounts","_type":"person","_id":"2","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}

  说明插入成功

例如2:

curl -H "Content-Type: application/json" -X PUT  'localhost:9200/accounts/person/4' -d '{"user":"李四","title": "软件工程师","desc":"系理集成"}'

  系统提示:

{"_index":"accounts","_type":"person","_id":"","_version":,"result":"created","_shards":{"total":,"successful":,"failed":},"_seq_no":,"_primary_term":}

说明插入成功。

可以使用PUT、POST插入数据,需要制定插入数据的数据格式,用 -H "Content-Type: application/json"制定为json格式。

2、数据查询

curl 'localhost:9200/accounts/person/4?pretty'

系统返回:

{
"_index" : "accounts",
"_type" : "person",
"_id" : "",
"_version" : ,
"found" : true,
"_source" : {
"user" : "李四",
"title" : "软件工程师",
"desc" : "系理集成"
}
}

说明查询成功。如果查询一个不存在id的记录,如命令:

curl 'localhost:9200/accounts/person/5?pretty'

id等于5的person因为没有对应的记录,所以,系统返回:

{
"_index" : "accounts",
"_type" : "person",
"_id" : "",
"found" : false
}

3、删除记录

删除记录就是发出 DELETE 请求。

最新文章

  1. [转] dpkg-deb命令
  2. hdu 2874 Connections between cities [LCA] (lca->rmq)
  3. JS-010-覆盖率测试工具 JSCoverage 初识
  4. list.clear()和list=null的区别
  5. NOIP2011 计算系数
  6. WPF之Treeview控件简单用法
  7. 使用require.js时,解决AMD封装jquery1.4.1的问题。
  8. 3450: Tyvj1952 Easy
  9. C#基本功之委托和事件
  10. BSA Network Shell系列-nlogin命令
  11. Zsh安装及常用操作
  12. react_app 项目开发
  13. <自动化测试方案_1>第一章、为什么要做自动化测试?(Why)
  14. 二、xadmin----简单使用
  15. Mongoose简介
  16. 【SCOI2010】序列操作
  17. 蜕变成蝶~Linux设备驱动之异步通知和异步I/O
  18. 响铃:蜗牛读书“文”、网易云信“武”:游戏之外网易的AB面
  19. 第六章 对象作用域与servlet事件监听器
  20. Retrofit2使用初探

热门文章

  1. A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/local/eclipse/
  2. C#-循环语句(六)
  3. Windows Server 2016-Active Directory复制概念(一)
  4. Unity与安卓开发的一些路径知识
  5. Gradle: Gradle Wrapper
  6. php的register_long_arrays可以关闭以提高性能
  7. C语言经典例题(菜鸟教程100例)
  8. python3编写网络爬虫23-分布式爬虫
  9. 【Linux基础】awk命令
  10. 轮播图插件swiper 的使用