Last active
May 29, 2020 12:07
-
-
Save bencrouse/9318223f9f179d4cfadca548bb695a87 to your computer and use it in GitHub Desktop.
Brand aggregation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Workarea | |
module Search | |
class Brands | |
include ProductDisplayRules | |
def all_results | |
buckets = Array.wrap(response.dig('aggregations', 'all_brands', 'buckets')) | |
buckets.map { |b| b['key'] } | |
end | |
def response | |
@response ||= Search::Storefront.search( | |
query: { bool: { must: product_display_query_clauses } }, | |
aggs: { 'all_brands' => { terms: { field: 'facets.brand', size: 99999 } } } | |
) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so is this aggregation is applied on complete product list which is available or just applied on new-products??