添加索引: put方式 (我加的是 百渡)
http://localhost:9200/百渡
返回值:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "百渡"
}
添加索引数据类型: post方式
http://localhost:9200/百渡/product/_mapping?include_type_name=true
请求头: Content-Type:application/json
请求值: postman post方法raw
{
"product" : {
"properties":{
"title" :{
"type" : "text",
"index" : "true"
},
"desc" :{
"type" : "text",
"index" : "false"
},
"price" :{
"type" : "double",
"index" : "false"
},
"onSale" :{
"type" : "boolean"
},
"type" : {
"type" : "integer"
},
"createDate" :{
"type" : "date"
}
}
}
}
返回值 :
{
"acknowledged": true
}
添加数据到索引: post方式
http://localhost:9200/百渡/product/
请求头: Content-Type:application/json
请求值: postman post方法raw
{
"title" : "msy正在百度",
"desc" : "你说你爱了不该爱的人",
"price" : "33.6",
"onSale" : "true",
"type" : 2 ,
"createDate" : "2021-11-25"
}
返回值:
{
"_index": "百渡",
"_type": "product",
"_id": "CSrlJ34BH7Of2YI2lGJB",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
搜索 get方式
http://localhost:9200/百渡/product/_search
{
"took": 82,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "百渡",
"_type": "product",
"_id": "CSrlJ34BH7Of2YI2lGJB",
"_score": 1,
"_source": {
"title": "msy正在百度",
"desc": "你说你爱了不该爱的人",
"price": "33.6",
"onSale": "true",
"type": 2,
"createDate": "2020-11-15"
}
},
{
"_index": "百渡",
"_type": "product",
"_id": "Cyr-J34BH7Of2YI2mGIx",
"_score": 1,
"_source": {
"title": "msy正在happy",
"desc": "你的心中满是伤痕",
"price": "33.6",
"onSale": "true",
"type": 2,
"createDate": "2020-11-15"
}
}
]
}
}
根据id搜索 get 请求 后面是文档的id CSrlJ34BH7Of2YI2lGJB
http://localhost:9200/百渡/product/CSrlJ34BH7Of2YI2lGJB
返回值:
{"_index":"百渡","_type":"product","_id":"CSrlJ34BH7Of2YI2lGJB","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{
"title" : "msy正在百度",
"desc" : "你说你爱了不该爱的人",
"price" : "33.6",
"onSale" : "true",
"type" : 2 ,
"createDate" : "2020-11-15"
}}
删除索引 delete请求
http://localhost:9200/百渡/
返回结果:
{
"acknowledged": true
}