检查健康状态
curl 'localhost:9200/_cat/health?v'
获得集群中的节点列表
curl 'localhost:9200/_cat/nodes?v'
列出所有的索引
curl -XGET http://localhost:9200/_cat/indices?v
curl -XGET http://localhost:9200/track/_mapping?pretty
curl -XGET http://localhost:9200/track/crm_log/_mapping?pretty
精确查询
curl -XGET 'http://localhost:9200/track/crm_log/_search?pretty' -d '{
"query" : {
"term" : { "url" : "https://infosalons.com/vscenter/visitor/confirmation.aspx?id=123&e=abc@def.com&exh=abcd" }
}
}'
curl -XPOST 'http://localhost:9200/track/crm_log/_search?pretty' -d '{
"query" : {
"term" : { "domain" : "ali.infosalons.com.cn" }
},"sort" : [{ "createTime" : {"order" : "desc"}} ]
}'
curl -XPOST 'http://localhost:9200/track/crm_log/_search?pretty' -d '{
"query" : {
"term" : { "domain" : "ali.infosalons.com.cn" }
},
"from":0,
"size":20
}'
知道前缀的查询
curl -XPOST 'http://localhost:9200/track/crm_log/_search?pretty' -d '{
"query": {
"prefix": {
"url": {
"value": "https://ali.infosalons.com.cn/vscenter/visitor/confirmation.aspx?id="
}
}
}
}'
查询结果输出到文档
curl -XPOST 'http://localhost:9200/track/crm_log/_search?pretty' -d '{
"query": {
"prefix": {
"url": {
"value": "https://ali.infosalons.com.cn/vscenter/visitor/confirmation.aspx?id="
}
}
}
}' > 1.txt
模糊查询,支持通配符,如*
curl -XPOST 'http://localhost:9200/track/crm_log/_search?pretty' -d '{
"query":{
"bool":{
"must":[
{
"wildcard":{
"url":"https://ali.infosalons.com.cn/vscenter/visitor/confirmation.aspx?id=*"
}
}
]
}
},
"from":0,
"size":70
, "sort" : [{ "createTime" : {"order" : "asc"}} ]
}' > 2.txt
组合多条件查询
{
"query": {
"bool": {
"minimum_should_match": 1,
"must": [{
"match": {
"XB": "2 "
}
},
{
"wildcard": {
"XM": "王*"
}
}
],
"should": [{
"range": {
"CSRQ": {
"gte": "2010-09-01",
"lte": "2014-09-01"
}
}
}]
}
},
"from": 0,
"size": 10
}
本文内容到此结束,更多内容可关注公众号

本文详细介绍了使用Elasticsearch进行各种查询的方法,包括健康状态检查、节点列表获取、索引管理、精确查询、前缀查询、模糊查询以及多条件组合查询,提供了丰富的curl命令实例,帮助读者快速掌握Elasticsearch的数据检索能力。
1039

被折叠的 条评论
为什么被折叠?



