Elasticearch(用POSTMAN测试)
程序员文章站
2022-07-12 13:34:10
...
创建索引库
PUT/POST方式提交
http://localhost:9200/my_course
地址: http://localhost:9200/my_course
带上下方JSON数据
举例:用POSTMAN提交找到Body中的raw并以JSON数据提交
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
}
提交成功后应返回以下JSON数据
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "my_course"
}
设置映射
POST提交
http://localhost:9200/my_course/doc/_mapping
地址: http://localhost:9200/my_course/doc/_mapping
带上下方JSON数据
举例:用POSTMAN提交找到Body中的raw并以JSON数据提交
{
"properties": {
"description": {
"type": "text",
"analyzer": "ik_max_word", //是否用ik
"search_analyzer": "ik_smart"
},
"name": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"pic": {
"type": "text",
"index": false
},
"price": {
"type": "float"
},
"studymodel": {
"type": "keyword"
},
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd"
}
}
}
提交成功后应返回以下数据
{
"acknowledged": true
}
把数据写入索引库
POST提交
http://localhost:9200/my_course/doc/3
http://localhost:9200/my_course/doc/3 注:后面跟的3是数据的id
带上下方JSON数据
举例:用POSTMAN提交找到Body中的raw并以JSON数据提交
{
"name": "java编程基础",
"description": "java语言是世界第一编程语言,在软件开发领域使用人数最多。",
"pic":"group1/M00/00/01/wKhlQFqO4MmAOP53AAAcwDwm6SU490.jpg",
"studymodel": "201001" ,
"timestamp":"2020-01-28 18:28:58"
}
提交成功后应返回以下数据
{
"_index": "my_course",
"_type": "doc",
"_id": "3", //这里的id就是上面地址跟的参数id
"_version": 1,
"result": "created",
"_shards": {
"total": 1,
"successful": 1, //成功
"failed": 0
},
"_seq_no": 2,
"_primary_term": 1
}
查询
GET提交
http://localhost:9200/my_course/doc/_search?q=name:java
http://localhost:9200/my_course/doc/_search?q=name:java
注:q=是固定语法,而name是根据name去查,如果改成description就意思是根据description去查询
:后面跟的是查询内容
查询成功应返回以下数据
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.9331132,
"hits": [
{
"_index": "my_course",
"_type": "doc",
"_id": "3",
"_score": 0.9331132,
"_source": {
"name": "java编程基础",
"description": "java语言是世界第一编程语言,在软件开发领域使用人数最多。",
"pic": "group1/M00/00/01/wKhlQFqO4MmAOP53AAAcwDwm6SU490.jpg",
"studymodel": "201001",
"timestamp": "2020-01-28 18:28:58"
}
}
]
}
}
删除
DELETE提交
http://localhost:9200/my_course
http://localhost:9200/my_course 删除索引库
提交成功后应返回以下数据、
{
"acknowledged": true
}
推荐阅读
-
用缓存实现静态页面的测试
-
postman+json+springmvc测试批量添加实例
-
自动化测试工具开发用什么语言(页面自动化测试工具使用)
-
postman测试post请求参数为json类型的实例讲解
-
spring boot2.0.4集成druid,用jmeter并发测试工具调用接口,druid查看监控的结果
-
骁龙865+首发UFS 3.1 iQOO 3晒KPL比赛用机测试成绩
-
自动化测试工具开发用什么语言(页面自动化测试工具使用)
-
html5测试网站代码(教你用html做个简单的网页)
-
Python使用Flask实现RESTful API,使用Postman工具、requests库测试接口
-
怎么用苹果Apple Watch手表测试心率心跳?