Elasticsearch学习笔记——常用命令

1.创建一个名字为index的topic

curl -XPUT http://localhost:9200/index

2.创建一个mapping

curl -XPOST http://localhost:9200/index/fulltext/_mapping -H 'Content-Type:application/json' -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word"
            }
        }

}'

3.删除一个文档,按照id来删除

curl -XDELETE 'http://localhost:9200/index3/fulltext3/272'

4.通过query来删除文档

不同版本之间的es不太一样,6.2的参考

https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-delete-by-query.html

比如使用kibana里面的dev tool,就可以删掉所有schema字段是“xxxx”的数据

POST xxxxx_2019-12-09/_delete_by_query
{
  "query": { 
    "match": {
      "schema": "xxxx"
    }
  }
}
原文地址:https://www.cnblogs.com/tonglin0325/p/10095044.html