elastic 基本操作

官方参考文档:

https://www.elastic.co/guide/cn/elasticsearch/guide/current/index-doc.html

1、查看 有哪些索引:

 curl 'localhost:9200/_cat/indices?v'

2、添加索引:

 curl -XPUT 'localhost:9200/customer?pretty'
 curl 'localhost:9200/_cat/indices?v'

3、删除索引

  

 curl -XDELETE 'localhost:9200/customer?pretty'
 curl 'localhost:9200/_cat/indices?v'

4、更新数据

   

curl -XPOST 'localhost:9200/_index/_type/_id/_update?pretty' -d '
curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '
{
  "doc": { "name": "Jane Doe", "age": 20 }
}

查看原来的数据

curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d '

  {"index":{"_id":"1"}}

  {"name": "John Doe" }

  {"index":{"_id":"2"}}

  {"name": "Jane Doe" }

http://localhost:9200/indexName/typeName/_update_by_query
  { "script": {"source":"ctx._source['user_name']='LsiuLi';ctx._source['assignedto_id']='123';"}, "query": {"term": {"user_id": 60} }


 批量处理:

 下面语句批处理执行更新id为1的数据然后执行删除id为2的数据


  curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d '

  {"update":{"_id":"1"}}

  {"doc": { "name": "John Doe becomes Jane Doe" } }

  {"delete":{"_id":"2"}}

  '
参考链接:https://www.cnblogs.com/pilihaotian/p/5830754.html
原文地址:https://www.cnblogs.com/cbugs/p/11498626.html