Elasticsearch学习笔记——常用命令

1.创建索引,名字为index

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.查看mapping

curl -XPUT http://localhost:9200/xxx/yyy/_mapping

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

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

5.通过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"
    }
  }
}

6.es的task api,参考

http://xiaorui.cc/archives/3089

7.scroll查看数据,from+size查询最多只能查10000

参考:https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-scroll.html

curl -XPOST -H 'Content-Type: application/json' http://localhost:9200/_search/scroll -d@data.json

data.json

{
    "scroll" : "1m",
    "scroll_id" : "xxxxxxxx"
}

8.删除一个索引

curl -XDELETE http://ip:port/xxxx

  

 

posted @ 2018-12-10 10:22  tonglin0325  阅读(355)  评论(0编辑  收藏  举报