es常用操作
查询所有索引
GET _cat/indices
查询索引下所有数据
GET test/_search
#同下
GET test/_search
{
"query": {
"match_all": {}
}
}
全文检索
#查询test下name为zhangsan的记录
GET test/_search
{
"query": {
"match": {
"name": "zhangsan"
}
}
}
更改单机索引yellow状态
PUT /_settings
{
"number_of_replicas": 0
}
更改shard数量
#es配置文件中添加
cluster.max_shards_per_node:10000
#通过kibana临时修改
PUT /_cluster/settings
{
"transient":{
"cluster":{
"max_shards_per_node":10000
}
}
}
查询索引相关信息
#查看索引相关信息
curl --location --request GET 'http://localhost:9200/animals'
#查看索引的文档总数
curl --location --request GET 'http://localhost:9200/animals/_count'
#查看以animals开头的索引
curl --location --request GET 'http://localhost:9200/_cat/indices/animals*?v&s=index'
#查看状态为绿的索引
curl --location --request GET 'http://localhost:9200/_cat/indices?v&health=green'
更改索引查询偏移值
put _settings
{
"index" : {
"highlight.max_analyzed_offset" : 90000000
}
}
清空索引内容
POST index_name/_delete_by_query
{
"query":{
"match_all":{}
}
}