我是弹性搜索的新手,我试图通过热门搜索聚合获得结果 但它只给了我十大结果我如何通过聚合在组中进行分页。
这是我发送的请求
{
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"title": "Fortune"
}
}
]
}
},
"aggs": {
"by_district": {
"terms": {
"field": "product_id"
},
"aggs": {
"tops": {
"top_hits": {
"size": 1
}
}
}
}
},
"from": 0,
"size": 0
}
我得到的结果
{
"took": 13,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 32,
"max_score": 0,
"hits": [
]
},
"aggregations": {
"by_district": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 7,
"buckets": [
{
"key": "4085",
"doc_count": 4,
"tops": {
"hits": {
"total": 4,
"max_score": 6.1574936,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "5387",
"_score": 6.1574936,
"_source": {
"suggest": "Fortune Refined Sunflower Oil",
"title": "Fortune Refined Sunflower Oil",
"phonetic": "Fortune Refined Sunflower Oil",
"product_id": "4085",
"variation_id": "5387",
"unit": "5 LTR JAR"
}
}
]
}
}
},
{
"key": "4086",
"doc_count": 3,
"tops": {
"hits": {
"total": 3,
"max_score": 6.142435,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "5390",
"_score": 6.142435,
"_source": {
"suggest": "Fortune Refined Cottonseed Oil",
"title": "Fortune Refined Cottonseed Oil",
"phonetic": "Fortune Refined Cottonseed Oil",
"product_id": "4086",
"variation_id": "5390",
"unit": "5 LTR JAR"
}
}
]
}
}
},
{
"key": "4804",
"doc_count": 3,
"tops": {
"hits": {
"total": 3,
"max_score": 5.9258366,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "6425",
"_score": 5.9258366,
"_source": {
"suggest": "Fortune Refined Soyabean Oil",
"title": "Fortune Refined Soyabean Oil",
"phonetic": "Fortune Refined Soyabean Oil",
"product_id": "4804",
"variation_id": "6425",
"unit": "1 LTR"
}
}
]
}
}
},
{
"key": "4820",
"doc_count": 3,
"tops": {
"hits": {
"total": 3,
"max_score": 5.9258366,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "6464",
"_score": 5.9258366,
"_source": {
"suggest": "Fortune Rice Bran Oil",
"title": "Fortune Rice Bran Oil",
"phonetic": "Fortune Rice Bran Oil",
"product_id": "4820",
"variation_id": "6464",
"unit": "1 LTR"
}
}
]
}
}
},
{
"key": "1014",
"doc_count": 2,
"tops": {
"hits": {
"total": 2,
"max_score": 6.1574936,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "1324",
"_score": 6.1574936,
"_source": {
"suggest": "Fortune Rozana Basmati Rice",
"title": "Fortune Rozana Basmati Rice",
"phonetic": "Fortune Rozana Basmati Rice",
"product_id": "1014",
"variation_id": "1324",
"unit": "5 KG"
}
}
]
}
}
},
{
"key": "1026",
"doc_count": 2,
"tops": {
"hits": {
"total": 2,
"max_score": 5.6601067,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "1341",
"_score": 5.6601067,
"_source": {
"suggest": "Fortune Everyday Full Grain Rice",
"title": "Fortune Everyday Full Grain Rice",
"phonetic": "Fortune Everyday Full Grain Rice",
"product_id": "1026",
"variation_id": "1341",
"unit": "1 Kg"
}
}
]
}
}
},
{
"key": "4812",
"doc_count": 2,
"tops": {
"hits": {
"total": 2,
"max_score": 5.4391136,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "6445",
"_score": 5.4391136,
"_source": {
"suggest": "Fortune Kachi Ghani Mustard Oil",
"title": "Fortune Kachi Ghani Mustard Oil",
"phonetic": "Fortune Kachi Ghani Mustard Oil",
"product_id": "4812",
"variation_id": "6445",
"unit": "1 LTR JAR"
}
}
]
}
}
},
{
"key": "4861",
"doc_count": 2,
"tops": {
"hits": {
"total": 2,
"max_score": 7.4589143,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "6532",
"_score": 7.4589143,
"_source": {
"suggest": "Fortune Besan",
"title": "Fortune Besan",
"phonetic": "Fortune Besan",
"product_id": "4861",
"variation_id": "6532",
"unit": "1 KG"
}
}
]
}
}
},
{
"key": "610",
"doc_count": 2,
"tops": {
"hits": {
"total": 2,
"max_score": 5.9555407,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "840",
"_score": 5.9555407,
"_source": {
"suggest": "Fortune Soya Chunks",
"title": "Fortune Soya Chunks",
"phonetic": "Fortune Soya Chunks",
"product_id": "610",
"variation_id": "840",
"unit": "1 KG"
}
}
]
}
}
},
{
"key": "714",
"doc_count": 2,
"tops": {
"hits": {
"total": 2,
"max_score": 6.142435,
"hits": [
{
"_index": "product_surat",
"_type": "surat",
"_id": "970",
"_score": 6.142435,
"_source": {
"suggest": "Fortune Vivo Blended Oil",
"title": "Fortune Vivo Blended Oil",
"phonetic": "Fortune Vivo Blended Oil",
"product_id": "714",
"variation_id": "970",
"unit": "1 LTR POUCH"
}
}
]
}
}
}
]
}
}
}
根据回复我只能在aggregate.buckets中获得25次点击数,但我没有得到其他7个结果。
那么如何才能获得这些结果呢?如果我想一次对5种产品进行分页,我该如何实现呢?
感谢您的帮助! : - )