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
本文只发表于博客园和tonglin0325的博客,作者:tonglin0325,转载请注明原文链接:https://www.cnblogs.com/tonglin0325/p/10095044.html

浙公网安备 33010602011771号