你一定是在理解结果时弄错了,
结果
{u'_shards': {u'failed': 0, u'skipped': 0, u'successful': 5, u'total': 5}
表示您的索引“scapy”的数据位于 5 个不同的分片中,您的搜索查询从这 5 个不同的分片中得到结果。
所以结果一定是这样的:
{
"took": 1651,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 10,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2221327255,
"max_score": 1,
"hits": [
{
"_index": "test_index",
"_type": "logs",
"_id": "BL1E-F8BH3R02gVcxkPc",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.1"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "Cr1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.1"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "Eb1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "F71E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "KL1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "LL1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "NL1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "R71E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "Sb1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
},
{
"_index": "test_index",
"_type": "logs",
"_id": "TL1E-F8BH3R02gVcxkPd",
"_score": 1,
"_source": {
"deviceType": "4",
"appVersion": "2.1.2"
}
}
]
}
}
hits中有10个项目,因为结果返回的默认大小是10,所以你可以在你的查询dsl中设置大小,
GET /_search
{
"from" : 0, "size" : 10,
"query" : {
"term" : { "user" : "kimchy" }
}
}