一、集群接口
1、健康状态
curl -X GET "http://localhost:9200/_cat/health?v"
2、集群node
curl -X GET "http://localhost:9200/_cat/nodes?v"
3、索引列表
curl -X GET "http://localhost:9200/_cat/indices?v"
二、索引
1、创建索引
//curl -X PUT "localhost:9200/[索引名]?pretty"
curl -X PUT "http://localhost:9200/test-customer?pretty"
2、创建索引,配置mappings
curl -XPUT 'http://localhost:9200/test-customer' -H 'Content-Type: application/json' -d'
{
"settings" : {
"index.number_of_shards" : 3
},
"mappings" : {
"_doc" : { //_doc 为index的type
"properties" : {
"name": {"type": "keyword"},
"title": {"type": "text", "index": "true"},
"price": {
"type": "scaled_float",
"scaling_factor": 100
}
}
}
}
}'
3、删除索引
curl -X DELETE "http://localhost:9200/test-customer?pretty"
4、添加文档
PUT协议,Json格式文档,_doc 为index的type
curl -X PUT "http://localhost:9200/test-customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "John Doe"
}'
5、通过id查询文档记录
curl -X GET "http://localhost:9200/test-customer/_doc/1?pretty"
6、更新文档
curl -X POST "http://localhost:9200/test-customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'{
"name":"John Doe",
"title":"防螨虫床上用品四件套",
"price":"65.00",
"firename":"1111aaaa",
"uuid":"1111111"
}'
7、删除文档
curl -X DELETE "http://localhost:9200/test-customer/_doc/1?pretty"