检查健康状态
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
}
本文内容到此结束,更多内容可关注公众号