如何调整ONGRFilterBundle动态聚合筛选默认选项数量以获取全部选项?
How to Fetch All Options in ONGRFilterBundle's Dynamic Aggregate Filter
Got it! The default limit of 10 options in the dynamic_aggregate filter comes from Elasticsearch's default aggregation bucket size, which ONGR's bundle uses out of the box. To get all available options instead, you just need to add the size option to your filter configuration and set it to a sufficiently large value (or 0 if you're using an Elasticsearch version that supports it—though a high explicit number like 1000 is safer to avoid unexpected behavior).
Here's your updated configuration with the necessary change:
ongr_filter_manager: managers: # ... your existing manager config filters: dynamic_attributes: type: dynamic_aggregate request_field: attributes document_field: attributes>attributes.value options: name_field: attributes.name show_zero_choices: false size: 1000 # Add this line to override the default 10 limit
Quick Explanation:
- The
sizeoption directly controls how many aggregation buckets (your filter options) Elasticsearch returns. - If you know the exact maximum number of options your
attributesfield can have, you can setsizeto that number. If you're unsure, a high value like1000will cover most use cases without performance issues (as long as you don't have tens of thousands of unique options—if you do, you might want to reconsider the UX of showing all options at once!).
内容的提问来源于stack exchange,提问作者Borja Pombo
相关产品推荐
相关产品推荐

