Elasticsearch 测试两部曲,使用的是7.6的版本
- 创建索引
- 向索引添加文档
索引操作【Index APIs 官方文档】
1 创建索引
curl -X PUT http://localhost:9200/test01
# {"acknowledged":true,"shards_acknowledged":true,"index":"test01"}
2 获取索引信息
curl -X GET http://localhost:9200/test01
# {"test01":{"aliases":{},"mappings":{},"settings":{"index":{"creation_...
3 删除索引
curl -X DELETE http://localhost:9200/test01
# {"acknowledged":true}
文档操作【Document APIs 官方文档】
1 添加文档
curl -X PUT http://localhost:9200/test01/_doc/doc001 -H "Content-Type":"application/json" -d {\"name\":\"User01\"}
# {"_index":"test01","_type":"_doc","_id":"doc001","_version":1,"result":"created...
2 获取文档信息
curl -X GET http://localhost:9200/test01/_doc/doc001
# {"_index":"test01","_type":"_doc","_id":"doc001","_version":1,"_seq_no":1,"_primary_t...
3 删除文档
curl -X DELETE http://localhost:9200/test01/_doc/doc001
# {"_index":"test01","_type":"_doc","_id":"doc001","_version":2,"result":"deleted...
搜索文档
匹配
curl -X GET http://localhost:9200/test01/_search -H "Content-Type":"application/json" -d "{\"query\":{\"match_phrase\":{\"name\":\"User01\"}}}"