关于ES使用Postman操作学习

**使用环境: **
JDK: 1.8
电脑:win7
PostMan :不限
ES: 5.2.0
正文:
下面我想创建一个索引,关于我数据库映射的参数分别是id,name,address。三个字段

向输入框内添加的格式代码:

{
   "settings": {
       "number_of_shards": 3,
       "number_of_replicas": 2
   },
   "mappings": {
       "doc": { //我用的5.20,7之后的需要把doc改为_doc(后续查询会接触到)
           "dynamic": "false",
           "properties": {
               "id": {
                   "type": "long",
                   "index": false // 是否被索引,如果为true就会被索引,会被查询到,为false则不会被查询到
               },
               "name": {
                   "type": "keyword",
                   "index": true
               },
               "address": {
                   "type": "keyword", // 关键字;如果根据这个字段进行查询必须是全名称,负责搜索不到对应内容
                   "index": true
               }
           }
       }
   }
}

点击sent按钮。出现{
"acknowledged": true,
"shards_acknowledged": true
}代表成功!

下面讲一下es的查询(以下es是7+);
全量查询http://localhost:9200/table/_search

主键查询http://localhost:9200/table/_doc/_id

主键查询解释:http://localhost:9200是ip和端口,table是表名也就是你的索引名,_doc是从es7+后的type,_id必须是你建索引的主键,
如我要查询主键为12的数据,其写法为:http://localhost:9200/table/_doc/12

条件查询http://localhost:9200/table/_search?q=_id:355
解释:_id是你要查询的字段,355是字段的value(格式一定要正确!)。

匹配查询http://localhost:9200/table/_search

分页查询http://localhost:9200/table/_search

分页过滤(只显示_id的字段):http://localhost:9200/table/_search

组合查询http://localhost:9200/table/_search

posted @ 2022-06-24 10:13  景伟·郭  阅读(1949)  评论(0)    收藏  举报