# Cluster Health GET _cat/health?v # list of nodes GET /_cat/nodes?v
#List All Indices GET /_cat/indices?v
# Create an Index PUT /customer?pretty GET /_cat/indices?v # Index and Query a Document PUT /customer/external/1?pretty { "name": "John Doe" } GET /customer/external/1?pretty DELETE /customer/external/1
# Delete an Index DELETE /customer?pretty
可以看出Elasticsearch 的 REST API基本格式:
<REST Verb> /<Index>/<Type>/<ID>
索引/替换文档
1 2 3 4 5 6 7 8 9 10 11
# Indexing/Replacing Documents PUT /customer/external/1?pretty { "name": "John Doe" }
# using the POST verb instead of PUT since we didn’t specify an ID POST /customer/external?pretty { "name": "Jane Doe" }
使用 PUT 方法需要明确指定 ID,两次 PUT 的 id 相同则是替换之前的文档,第二次 id 不同则是创建新的文档