我试图在Getting Started之后学习弹性搜索。但是在查询时null
除了match_all
之外总是得到match_all
。
当我执行如下所示的curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"query": {
"match_all": {}
}
}' | head -20
查询时,它可以正常工作:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0{
"took" : 15,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "bank",
"_type" : "acount",
"_id" : "_buck",
"_score" : 1.0,
"_source":{"index":{"_id":"1"}}
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
{"index":{"_id":"6"}}
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
curl: (23) Failed writing body (8282 != 16384)
输出(1):
match
接下来,我执行filter
和其他命令,例如aggr
,size
,curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"query": {
"match": {"age": 32}
}
}' | head -20
,
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 261 100 193 100 68 31535 11111 --:--:-- --:--:-- --:--:-- 38600
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
输出(2):
hits.hits = [ ]
为什么输出中的32
(2)?根据输出(1),琥珀的年龄是{{1}},不是吗?