Reputation: 33
When using GetCandy, if I make a request for products, I can see in the response a key called aggregation.
CandyClient::Products()->Search($payload);
This seems to display a max of 10 buckets. How can I increase the number of buckets returned here? I need it to instead return all buckets so I can update aggregation count on the front end.
E.G.
meta: {sort: [{popularity: "desc"}], category_page: false,…}
aggregation: {features: {doc_count: 899, features: {doc_count_error_upper_bound: 5, sum_other_doc_count: 587,…}},…}
brand: {doc_count: 899, brand: {doc_count_error_upper_bound: 11, sum_other_doc_count: 538,…}}
brand: {doc_count_error_upper_bound: 11, sum_other_doc_count: 538,…}
buckets: [{key: "Melissa & Doug", doc_count: 55}, {key: "Papo", doc_count: 50},…]
0: {key: "Melissa & Doug", doc_count: 55}
1: {key: "Papo", doc_count: 50}
2: {key: "Le Toy Van", doc_count: 42}
3: {key: "Marvel", doc_count: 40}
4: {key: "Disney Princess", doc_count: 39}
5: {key: "A.B. Gee", doc_count: 29}
6: {key: "Sunnylife", doc_count: 29}
7: {key: "Fisher Price", doc_count: 28}
8: {key: "Toy Story", doc_count: 26}
9: {key: "Grimm's", doc_count: 23}
doc_count_error_upper_bound: 11
sum_other_doc_count: 538
doc_count: 899
...
Upvotes: 0
Views: 78
Reputation: 8840
Not sure about GetCandy here but I like to think that aggregation count is something that elasticsearch can calculate and return to you.
Basically I've come up with the below ES query where I've made use of the Cardinality Aggregation
on that field on which you are applying the Terms Aggregation
as well.
This would return the total count of unique values of that field.
POST <your_index_name>/_search
{
"query": {
.....
},
"size": 200,
"aggs": {
"terms_myagg": {
"terms": {
"field": "<your_field_name>",
"size": 200 <---- To return more buckets
}
},
"count_myagg": {
"cardinality": { <---- To return count of terms
"field": "<your_field_name>"
}
}
}
}
Also note that I've mentioned "size":200
here in order to return more bucket count in terms aggregation.
Not really sure how this would help, but I hope it does!!
Upvotes: 0
Reputation: 462
Currently, it's not possible, but we are looking at what the best way to add this as a config without being too specific to Elastic.
Upvotes: 0