Would you mind helping out a bit more? I tried doing an aggregation and failed to see how to do a top hits with a dynamic size based on if it's a single-page
I have some test documents setup
{
"_index": "new_test",
"_type": "new_test",
"_id": "AV-4MYCYlk1DjGsyQCzP",
"_score": 1,
"_source": {
"group": "A",
"allow_multiple": true,
"name": "AB"
}
},
{
"_index": "new_test",
"_type": "new_test",
"_id": "AV-4MZJVlk1DjGsyQCzQ",
"_score": 1,
"_source": {
"group": "A",
"allow_multiple": true,
"name": "AC"
}
},
{
"_index": "new_test",
"_type": "new_test",
"_id": "AV-4Ma0Klk1DjGsyQCzR",
"_score": 1,
"_source": {
"group": "B",
"allow_multiple": false,
"name": "BA"
}
},
{
"_index": "new_test",
"_type": "new_test",
"_id": "AV-4McCNlk1DjGsyQCzT",
"_score": 1,
"_source": {
"group": "B",
"allow_multiple": false,
"name": "BC"
}
},
{
"_index": "new_test",
"_type": "new_test",
"_id": "AV-4Mba0lk1DjGsyQCzS",
"_score": 1,
"_source": {
"group": "B",
"allow_multiple": false,
"name": "BB"
}
},
{
"_index": "new_test",
"_type": "new_test",
"_id": "AV-4MW3qlk1DjGsyQCzO",
"_score": 1,
"_source": {
"group": "A",
"allow_multiple": true,
"name": "AA"
}
}
"group" is say the book name, and "name" is just some data
This query is as far as I'm able to get:
GET /new_test/new_test/_search
{
"aggs":{
"group":{
"terms":{"field":"group"},
"aggs":{
"allow_multiple":{
"terms":{"field":"allow_multiple"}
}
}
}
}
}
Basically I want all 3 from group A to return, and only 1 from group B to show.
Any help would be greatly appreciated.