使用Kibana dev Tools 实现ElasticSearch文档的检索
1 查询所有索引
GET _search
{
"query": {
"match_all": { }
}
}
返回结果如下图所示:
{
"took" : 46,
"timed_out" : false,
"_shards" : {
"total" : 20,
"successful" : 20,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : ".kibana-event-log-7.8.0-000001",
"_type" : "_doc",
"_id" : "S1xHbHMBHlOTuWE2D6Um",
"_score" : 1.0,
"_source" : {
"event" : {
"provider" : "eventLog",
"action" : "starting"
},
"message" : "eventLog starting",
"@timestamp" : "2020-07-20T12:51:02.763Z",
"ecs" : {
"version" : "1.5.0"
},
"kibana" : {
"server_uuid" : "99afcd1f-c893-4d8b-95ae-626a0771cd82"
}
}
}
]
}
}
2 返回参数定义:
- took: 执行搜索耗时,毫秒为单位
- time_out: 搜索是否超时
- _shards: 多少分片被搜索,成功多少,失败多少
- hits: 搜索结果展示
- hits.total: 匹配条件的文档总数
- hits.hits: 返回结果展示,默认返回十个
- hits.max_score:最大匹配得分
- hits._score: 返回文档的匹配得分(得分越高,匹配程度越高,越靠前)
- _index 、_type、 _id 作为剥层定位到特定的文档
- _source 文档源
3 条件查询
3.1 查询所有索引中的地址名称
GET _search
{
"query": {
"match": {
"addressName": "金融大街"
}
}
}
返回结果如下:
3.2 查询指定索引下的地址名称
GET /test_data_jiangsu/_search
{
"query": {
"match": {
"ADDRESSNAME": "江苏省连云港市连云区墟沟街道长宁路长宁路社区4号楼1单元"
}
}
}
返回结果如下图:
3.3 查询指定索引的部分字段
POST /test_data_jiangsu/_search
{
"query": {
"match_all": {
} },
"_source": ["ADDRESSCODE", "ADDRESSNAME"]
}
返回结果如下图:
3.4 查询指定索引中地址名称包括A或者B的文档
POST /test_data_jiangsu/_doc/_search
{
"query": {
"bool": {
"should": [
{ "match": { "ADDRESSNAME": "江苏省连云港市1单元"} },
{ "match": { "ADDRESSNAME": "江苏省连云港市连云区墟沟街道长宁路长宁路社区4号楼2单元" } }
]
}
}
}
返回结果如下:
3.5 查询指定索引中地址名称包括A和B的文档
POST /test_data_jiangsu/_doc/_search
{
"query": {
"bool": {
"must": [
{ "match": { "ADDRESSNAME": "江苏省连云港市"} },
{ "match": { "ADDRESSNAME": "长宁路社区4号楼2单元" } }
]
}
}
}
返回结果如下:
还没有评论,来说两句吧...