elasticsearch 对文档建索引
接上篇 elasticsearch 启动运行 ,启动后即可索引json格式文档 给文档添加索引 PUT命令指定将文档添加到某个索引,需要唯一文档id,和k-v对格式的请求体 curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d' { "name": "John Doe" } ' 创建一个名为 customer 的索引(如果不存在)添加一个id=1的文档,存储文档并对 name 字段进行索引 返回 { "_index" : "customer", "_type" : "_doc", "_id" : "1", "_version" : 2, "result" : "updated", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 1, "_primary_term" : 4 } 因为是新文档,所以版本号_version 为1 查询文档 次数es集群中任一节点都可查询到该文档 curl -X GET "localhost:9200/customer/_doc/1?pretty" { "_index" : "customer", "_type" : "_doc",