Postman 操作 elasticsearch

您所在的位置:网站首页 postman查询id指定数据 Postman 操作 elasticsearch

Postman 操作 elasticsearch

2024-07-12 00:20| 来源: 网络整理| 查看: 265

1.elasticsearch 命令的基本格式

RESTful接口URL的格式:

  http://localhost:9200///[]

  其中index、type是必须提供的。id是可选的,不提供es回自动生成。index、type将信息进行分层,利于管理。index可以理解为数据库;type理解为数据表;id相当于数据表中记录的主键,是唯一的。

2.elasticsearch基本的增删改

1) 增加

  例如:向store索引中增加一些书籍,如果没有store这个索引,回自动创建

  PUT地址:http://localhost:9200/store/books/1

  Json内容:

{ "title": "Elasticsearch: The Definitive Guide", "name" : { "first" : "Zachary", "last" : "Tong" }, "publish_date":"2015-02-06", "price":"49.99" }

 

 

 通过elasticsearch-head查询结果:

 

 

 2)删除

  DELETE地址:http://localhost:9200/hello/books/1

 

 

查询结果:

 

 

 3)更改

①可以通过覆盖的方式更新

  PUT地址:http://localhost:9200/store/books/1

  JSON数据:

{ "title": "Elasticsearch: The Definitive Guide", "name" : { "first" : "Zachary", "last" : "Tong" }, "publish_date":"2016-02-06", "price":"99.99" }

 

 

 

 

 

 ② 通过_update API的方式单独更新你想要更新的

  POST地址:http://localhost:9200/store/books/2/_update

JSON内容:

{ "doc": { "price" : 88.88 } }

 

 

 

 

 

 3.elasticsearch查询

  elasticSearch查询分三种,一是浏览器查询,二是curl查询,三是请求体查询GET或POS。

  注:采用_search的模糊查询(包括bool过滤查询、 嵌套查询、range范围过滤查询等等),url可以不必指定type,只用指定index查询就行,具体例子看"2.1.4 elasticSearch查询 ③query基本匹配查询"节点的具体查询实例

1)浏览器查询

  ?pretty 返回格式化后的json,pretty参数表示返回结果格式美观

 

 

 3)GET查询

  GET地址:http://localhost:9200/store/books/2?pretty

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3