创建索引(PUT)
PUT /索引名
curl -X PUT http://10.20.20.214:9200/shopping
查询索引(GET /_cat/indices?v)
GET http://10.20.20.214:9200/_cat/indices?v
添加数据(POST /索引名/_doc 或者 PUT /索引名/_create)
curl -X POST http://10.20.20.214:9200/shopping/_doc -d ‘{"name":"zhangmingda", "age":23}‘ -H "Content-Type:application/json"
查询数据 (GET /索引名/_doc/索引ID 查单条数据 或者 GET /索引名/_search 查所有数据)
[root@vm10-20-9-45 ElasticSearch]# curl -X GET http://10.20.20.214:9200/shopping/_search?pretty=true { "took" : 438, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 6, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "shopping", "_type" : "_doc", "_id" : "4V9BSnsBL-0_1XxfCTs7", "_score" : 1.0, "_source" : { "name" : "zhangmingda", "age" : 23 } }, { "_index" : "shopping", "_type" : "_doc", "_id" : "10001", "_score" : 1.0, "_source" : { "name" : "zhangmingda", "age" : 23 } }, { "_index" : "shopping", "_type" : "_doc", "_id" : "10002", "_score" : 1.0, "_source" : { "name" : "zhangmingda", "age" : 23 } }, { "_index" : "shopping", "_type" : "_doc", "_id" : "10004", "_score" : 1.0, "_source" : { "name" : "zhangmingda", "age" : 23 } }, { "_index" : "shopping", "_type" : "_doc", "_id" : "519NSnsBL-0_1XxfIztW", "_score" : 1.0, "_source" : { "name" : "zhangmingda", "age" : 23 } }, { "_index" : "shopping", "_type" : "_doc", "_id" : "6F9NSnsBL-0_1XxfMjvj", "_score" : 1.0, "_source" : { "name" : "zhangmingda", "age" : 23 } } ] } }