我已经按照elasticsearch.org网站上的指南添加数据,然后测试搜索过滤器。
我收回了所有的记录,而不仅仅是第一张唱片。
我运行的命令是......
curl -XPOST 127.0.0.1:9200/bank/_search?pretty -d "{"query":{"match_all":{}},"size":1}"
我得到的结果是......
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "bank",
"_type" : "accounts",
"_id" : "AUkI69P6_5tX7kVBxTtE",
"_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"}
{"index":{"_id":"13"}}
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}
{"index":{"_id":"18"}}
{"account_number":18,"balance":4180,"firstname":"Dale","lastname":"Adams","age":33,"gender":"M","address":"467 Hutchinson Court","employer":"Boink","email":"daleadams@boink.com","city":"Orick","state":"MD"}
{"index":{"_id":"20"}}
{"account_number":20,"balance":16418,"firstname":"Elinor","lastname":"Ratliff","age":36,"gender":"M","address":"282 Kings Place","employer":"Scentric","email":"elinorratliff@scentric.com","city":"Ribera","state":"WA"}
{"index":{"_id":"25"}}
<SNIP>
请有人帮帮我。
由于
注意:我在Windows 7上
注意:我使用的是curl-7.34.0-rtmp-ssh2-ssl-sspi-zlib-winidn-static-bin-w64
答案 0 :(得分:0)
在完成回复之后,我可以说你确实只获得了一条记录。上面指定的用于检索一条记录的查询是正确的。 看起来您在索引的记录中几乎没有混淆。 “银行”索引中只有一个文档。这可以通过命中总大小来得出结论。
您已将仅包含一个_id字段的一个文档中包含“account_number”,“balance”的所有必需记录编入索引。相反,您应该在每条记录上存储具有唯一_id的各个记录。
可以采用以下可能的方式。
{
_index: ppp
_type: ppp_data
_id: 53dfc0d475f493e5201065a9
_score: 1
_source: {
_id: 53dfc0d475f493e5201065a9
{"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"}}
}
},
{
_index: ppp
_type: ppp_data
_id: 53dfc0d575f493e5201065b2
_score: 1
_source: {
_id: 53dfc0d575f493e5201065b2
{"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"}
{"index":{"_id":"13"}}
}
},
{
_index: ppp
_type: ppp_data
_id: 53dfc0d475f493e5201065sdf
_score: 1
_source: {
_id: 53dfc0d475f493e5201065sdf
{"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}
{"index":{"_id":"18"}}
}
}