[ElasticSearch-2]使用Postman调用RestAPI
ElasticSearch的Postman调用RestAPI
创建索引库
PUT提交
localhost:9200/tensquare_elasticsearch
创建索引库tensquare_elasticsearch
在索引库中创建类型
POST提交
localhost:9200/tensquare_elasticsearch/article
添加一个类型article,类型中的文档为title,content
bady中填写json字符串
{
"title":"spring教程",
"content":"spring框架教程"
}
返回
查询所有数据
GET提交
localhost:9200/tensquare_elasticsearch/article/_search
查询article文档中的所有数据
修改数据
PUT提交
修改id为AW7BpmG1bP46Cc5Wejic的文档
localhost:9200/tensquare_elasticsearch/article/AW7BpmG1bP46Cc5Wejic
返回数据 result变为updated ,created变为false
修改成功!!!!!
如果我们在地址中的ID不存在,则会创建新文档
以put形式提交以下地址:
localhost:9200/tensquare_elasticsearch/article/1
body:
{
"title":"十次方课程好给力",
"content":"知识点很多"
}
返回信息:
{
"_index": "articleindex",
"_type": "article",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true
}
按ID查询文档
GET方式请求
localhost:9200/tensquare_elasticsearch/article/1
基本匹配查寻
根据某列进行查询 get方式提交下列地址:
localhost:9200/tensquare_elasticsearch/article/_search?q=title:十次方
模糊查询
get方式提交下列地址:
localhost:9200/tensquare_elasticsearch/article/_search?q=title:*s*
删除文档
根据ID删除文档,删除ID为1
DELETE方式提交
localhost:9200/tensquare_elasticsearch/article/1