Closed dfelton closed 7 years ago
Hi @dfelton looks like you already have a solution. Would like to submit PR?
@okorshenko Yes I could certainly do that.
Would the Magento team prefer to use a value of 0
(deprecated in ElasticSearch 2.4, but still works), or a hard set large value for the bucket size?
@okorshenko
Actually I just noticed that ElasticSearch doesn't seem to be included in the Community Edition of Magento. Therefore I wouldn't know how to create a pull request for this particular issue as it is a EE specific problem.
Thanks dfelton!
@dfelton, thank you for your report. Please follow these guidelines for proper tracking of your issue. You can report Commerce-related issues in one of two ways: You can use the Support portal associated with your account or If you are a Partner reporting on behalf of a merchant, use the Partner portal.
GitHub is intended for Magento Open Source users to report on issues related to Open Source only. There are no account management services associated with GitHub.
@magento-engcom-team
Thank you I will communicate this issue and my findings through the Support Portal.
Does Magento have a forum or some other medium that it would be appropriate to report and discuss Enterprise specific issues in a public context? Sometimes can be difficult to find community driven discussion around Enterprise specific modules.
I am going to leave the GitHub issue open for exposure purposes but if you guys prefer it be closed I understand. Thank you.
Hi @dfelton you can visit the Forum or Community Slack magentocommeng.slack.com to discuss any Magento related questions
Elastic Search defaults its bucket size to
10
if not specified in the query.Magento\Elasticsearch\SearchAdapter\Query\Builder\Aggregation::buildBucket()
omits this parameter. Because of this, it is possible for ElastiSearch to omit results if more there are more than 10 possible results. This drastically impacts the Layered Navigation block in a negative way if any of the attribute filters are supposed to have more than 10 options to filter by.According to all ElasticSearch 2.0, 2.1, 2.2, 2.3, and 2.4, all of these Magento supported versions default size to 10. Quoted from their documentation page:
Preconditions
Steps to reproduce
Expected result
Actual result
Our Solution
We've extended
Magento\Elasticsearch\SearchAdapter\Query\Builder\Aggregation
, overriding thebuildBucket
method to add a hard coded "size" parameter with a value of 2000, which was suitable for our needs but others will have to determine their own appropriate value for this. ElasticSearch's documentation states that using "0" is deprecated as of 2.4, but I can confirm that it does still work.Source Code
(Assumes you already know how to build a basic module, I've only included what was added to an existing module in order to patch this bug)
app/code/VendorName/ModuleName/etc/di.xml
Add to your configuration:
app/code/VendorName/ModuleName/Magento/Elasticsearch/SearchAdapter/Query/Builder/Aggregation.php
Before Picture (max of 10 filter options per attribute show)
After Picture (all available filters now show)