如何在没有id的情况下将数据插入Elasticsearch

pro*_*014 5 elasticsearch

我将数据插入到ID为123的Elasticsearch

localhost:9200/index/type/123
Run Code Online (Sandbox Code Playgroud)

但我不知道下一个id会插入什么

如何在localhost:9200/index/type中将数据插入到没有id的Elasticsearch中?

Sid*_*ige 11

可以在不指定id的情况下执行索引操作.在这种情况下,将自动生成id.此外,op_type将自动设置为create.这是一个例子(注意POST使用而不是PUT):

$ curl -XPOST 'http://localhost:9200/twitter/tweet/' -d '{
    "user" : "kimchy",
    "post_date" : "2009-11-15T14:12:12",
    "message" : "trying out Elasticsearch"
}'
Run Code Online (Sandbox Code Playgroud)