
回复
Elasticsearch 使用RESTful API, 对应 CRUD commands: create, read, update, and delete。可以阅读如下链接学习详细内容。
原文档中少个-d选项,报错:"request body is required。已补充,如下:
curl -XPOST -H "Content-Type: application/json" 'http://localhost:9200/tutorial/helloworld/1' -d '{ "message": "Hello World!" }'
后面的参数是可以不添加的。命令如下。
curl -X GET -H "Content-Type: application/json" 'http://localhost:9200/tutorial/helloworld/1' '{ "message": "Hello World!" }'
curl -X GET -H "Content-Type: application/json" 'http://localhost:9200/tutorial/helloworld/1'
需要添加-d选项。
curl -X PUT -H "Content-Type: application/json" 'http://localhost:9200/tutorial/helloworld/1?pretty' -d '{ "message": "Hello, People!"}'
如何删除数据?文档中未提到。需要查询API文档 https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html。
curl -X DELETE -H "Content-Type: application/json" 'http://localhost:9200/tutorial/helloworld/1?pretty'
主要是帮助理解些ElasticSearch的核心概念,如下:
MySQL | ElasticSearch |
---|---|
Database | Index |
Table | Type |
Row | Document |
Column | Field |
Schema | Mapping |
Index | Everything is indexed |
SQL | Query DSL |
select * from … | Get http://… |
update table set … | Post http://… |
关于ElasticSearch的可视化界面查询了如下资料,但是其实都不太满意,可以适当看看。
最喜欢的工具是Elasticvue,这是个免费开源的浏览器插件。官方地址在:
该文档较老,API的版本已经不适用。只需要了解下相关的操作有哪些即可。如下:
通过这些参考文档,希望可以快速学习ElasticSearch的基本操作。