ElasticSearch部署与启动
PostMan中操作调用RestAPI
1.新建索引
以put方式提交,如:
http://localhost:9200/tensquare_elasticsearch
成功后返回:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "tensquare_elasticsearch"
}
2.新建文档
http://localhost:9200/tensquare_elasticsearch/article
成功后返回:
{
"_index": "tensquare_elasticsearch",
"_type": "article",
"_id": "AXF8wNJoeRSZVheYL50J",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true
}
3.查询全部文档
http://localhost:9200/tensquare_elasticsearch/article/_search
返回:
{
"took": 83,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "tensquare_elasticsearch",
"_type": "article",
"_id": "AXF8wNJoeRSZVheYL50J",
"_score": 1,
"_source": {
"title": "spring教程",
"content": "spring框架教程"
}
}
]
}
}
4.修改文档
http://localhost:9200/tensquare_elasticsearch/article/AXF8wNJoeRSZVheYL50J
红色部分为:id值(注意:当id值不存在的时候默认为添加操作,id值存在为修改操作。)
修改成功后返回:
{
"_index": "tensquare_elasticsearch",
"_type": "article",
"_id": "AXF8wNJoeRSZVheYL50J",
"_version": 2,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": false
}
5.按照id查询
http://localhost:9200/tensquare_elasticsearch/article/1
6.基本匹配查询
http://localhost:9200/tensquare_elasticsearch/article/_search?q=title:spring教程
7.模糊查询
http://localhost:9200/tensquare_elasticsearch/article/_search?q=title:*s*