1、修改操作
1、要删除Elasticsearch索引的分区下的数据
<index_name>是要删除数据的索引名称。这个命令会删除该索引下的所有数据。
powershell
POST /<index_name>/_delete_by_query
{
"query": {
"match_all": {}
}
}
2、删除特定条件下的数据
要删除age字段值为30的数据
powershell
POST /<index_name>/_delete_by_query
{
"query": {
"range": {
"age": {
"gte": 30,
"lte": 40
}
}
}
}
3、查询某个索引的所有内容
powershell
curl -u es_admin:'123456' -XGET http://localhost:9200/noah_branch_orglog_20230101/_search?scroll=1m -H 'Content-Type: application/json' -d'{"query": {"match_all": {}}}' > aa.txt
2、查询操作
1、分页查询并将结果导出到文件:
powershell
curl -u es_admin:'123456' -XPOST http://localhost:9200/noah_branch_orglog_20230428/_search -H 'Content-Type: application/json' -d'{"from": 0,"size": 1000,"query": {"match_all": {}}}' > aa.txt
2、设置分页查询的上限(默认是10000,超过会报错):
powershell
curl -u es_admin:'123456' -XPUT http://localhost:9200/noah_branch_orglog_20230101/_settings -H 'Content-Type: application/json' -d'{"max_result_window" : 2038160}'
3、查询某个索引下具体值:pretty以json格式展示:
powershell
curl -u es_admin:'123456' -XGET http://localhost:9200/noah_branch_orglog_20230428/_doc/223.103.235.222?pretty
4、指定索引统计(常用):
powershell
curl -u es_admin:'123456' -XGET http://localhost:9200/noah_branch_orglog_20230509/_count?pretty