参考 : elasticsearch中使用curl进行的简单查询_浅谈-CSDN博客_curl查询es某个索引数据
说明
- 查询多个index可以前缀加*号,如 test_index*
查看所有索引
curl http://127.0.0.1:9200/_cat/indices?v
查看单个索引信息
curl -XGET http://127.0.0.1:9200/test_index?pretty
精确查询
curl -H "Content-Type:application/json" -XGET http://127.0.0.1:9200/test_index/_search?pretty -d \
'{
"query": {
"bool": {
"must": [{
"term": {
"timestamp": "1639140845491"
}
}]
}
}
}'
查询两条数据
curl -H "Content-Type:application/json" -XGET http://127.0.0.1:9200/test_index/_search?pretty -d \
'
{
"query":{
"match_all":{
}
},
"size":2
}
'
范围查询
curl -H "Content-Type:application/json" -XGET http://127.0.0.1:9200/test_index/_search?pretty -d \
'
{
"query":{
"range":{
"timestamp":{
"gte": "1639140843491",
"lte": "1639140846491"
}
}
}
}
'
删除索引
curl -XDELETE http://127.0.0.1:9200/test_index