查询返回参数说明:
took: 返回数据库的毫秒数
time_out: 是否超时
_shards: 分片,相当于数据被拆分成了多少份,分别在每个分片上,当我们进行搜索时,会去这几个分片上或者他们对应的replicat上搜索
hits.total: 返回的文档总条数
hits.max_score: 对于一个serch的匹配度
hits.hits: 返回的文档的详细数据
不返回具体数据,只显示结果总数
查询status字段值为404的记录
GET /logstash-lmcs-lncore-2019.11.08/_search
{
"query": {
"match": {
"status": "404"
}
},
"size": 0
}
下面的hits中的total就是总数
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 49,
"max_score": 0,
"hits": []
}
}
多字段查询
GET /logstash-lmcs-lncore-2019.11.08/_search
{
"query": {
"bool": {
"must": [
{"match": {"status": "404"}},
{"match": {"remote_addr": "59.36.132.240"}}
]
}
}
}
只显示某些字段内容
GET /logstash-lmcs-lncore-2019.11.08/_search
{
"query": {
"bool": {
"must": [
{"match": {"status": "404"}},
{"match": {"remote_addr": "59.36.132.240"}}
]
}
},
"_source": ["status","@timestamp"]
}
根据某字段降序排序
"sort": [ {"price": "desc"} ]