Elasticsearch入门 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

Update API


  比如插入”twitter”的索引,并且索引类型为tweet,id为2的记录。如下代码:

curl -XPUT  'http://localhost:9200/twitter/tweet/2' -d '{
       "user":"kimchy",
      "post_date":"2012-12-12",
       “message”:”trying out ElasticSearch!”
}’

  添加成功后,其会返回操作状态,索引、类型、id等信息如下代码返回信息。

{
     "ok" : true,
     "_index" : "twitter",
     "_type" : "tweet",
     "_id" : "2"
}

  当然也可以不指定id对数据进行增加,系统会自动增加一个id,我们要用POST命令来实现。

curl -XPOST  'http://localhost:9200/twitter/tweet' -d '{
       "user":"jim",
      "post_date":"2015-05-12",
       “message”:”trying out ElasticSearch!”
}’
插入"twitter"的索引,并且索引类型为tweet,id为3的记录。