Skip to content

Instantly share code, notes, and snippets.

@bencrouse
Last active May 29, 2020 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bencrouse/9318223f9f179d4cfadca548bb695a87 to your computer and use it in GitHub Desktop.
Save bencrouse/9318223f9f179d4cfadca548bb695a87 to your computer and use it in GitHub Desktop.
Brand aggregation
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
@anushrishinde6
Copy link

so is this aggregation is applied on complete product list which is available or just applied on new-products??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment