创建索引
curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/index2 -d '{
"settings" : {
"number_of_shards" : 4,
"number_of_replicas" : 0
},
"mappings" : {
"properties" : {
"field1" : { "type" : "long" },
"field2" : { "type" : "text" }
}
}
}'
插入数据
curl -XPUT 'http://localhost:9200/index2/_doc/1' -H 'Content-Type: application/json' -d '{"field1" : 6651 ,"field2" : "111111"}' (_doc 名字)
普通查删
curl -XGET http://localhost:9200/index2/_doc/_search?q=field2:111111
查找索引全部数据
curl -XDELETE http://127.0.0.1:9200/x-x
删除索引
高级查询
curl -XGET 'http://127.0.0.1:9200/xxx/_doc/_search' -H "Content-Type: application/json" -d '{
"query": {
"match": {
""host_ip": "10.229.31.226"
}
}
}'
根据条件查找索引
curl -XGET 'http://localhost:9200/_cluster/health?pretty'
查看集群状态
curl -XPOST 'localhost:9200/xxxx/_search?pretty' -H "Content-Type: application/json" -d '{"query": { "match": {"ip.keyword": "xxx"}},"sort":{"create_time.keyword":{"order":"desc"}},"size": 1}'
排序查最新一条数据
curl -XPOST 'localhost:9200/xxxx/_search?pretty' -H "Content-Type: application/json" -d '{"query": {"bool": {"must": [{"match": {"ip.keyword": "行行行"}}],"filter": {"range": {"create_time.keyword": {"gte": "2021-04-02 12:00:07","lte": "2021-04-02 12:02:07"}}}}}}'
查询指定时间内并带过滤条件的数据(抓某行的的话可以利用 | grep xxx , 并且定向输出到数据 >>1.txt)
修改设置
修改字段设置
curl -i -H "Content-Type: application/json" -X PUT -d "{\"index.mapping.total_fields.limit\":\"2100\"}" http://127.0.0.1:9200/x-x/_settings/
查看下字段设置
curl -XGET 'http://127.0.0.1:9200/x-x/_settings'
curl -XGET http://127.0.0.1:9200/x-x/_search?pretty
查看es线程 cpu使用量
curl http://localhost:9200/_nodes/hot_threads
热线程