Skip to content

Instantly share code, notes, and snippets.

@jlsherrill
Created March 14, 2014 18:58
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 jlsherrill/9554412 to your computer and use it in GitHub Desktop.
Save jlsherrill/9554412 to your computer and use it in GitHub Desktop.
diff --git a/app/controllers/katello/api/v2/api_controller.rb b/app/controllers/katello/api/v2/api_controller.
index d5bc7c5..8857125 100644
--- a/app/controllers/katello/api/v2/api_controller.rb
+++ b/app/controllers/katello/api/v2/api_controller.rb
@@ -88,6 +88,7 @@ module Katello
@search_service.model = item_class
options[:per_page] = 1
options[:facets] = {facet_name => term}
+ options[:facet_filters] = options[:filters]
@search_service.retrieve('', 0, options)
diff --git a/app/models/katello/glue/elastic_search/items.rb b/app/models/katello/glue/elastic_search/items.rb
index a1a074d..f25736c 100644
--- a/app/models/katello/glue/elastic_search/items.rb
+++ b/app/models/katello/glue/elastic_search/items.rb
@@ -57,6 +57,7 @@ module Glue
all_rows = false
sort_by = search_options.fetch(:sort_by, 'name_sort')
sort_order = search_options[:sort_order] || 'ASC'
+ facet_filters = search_options[:facet_filters] || {}
total_count = 0
sort_by = format_sort(sort_by)
@@ -96,8 +97,9 @@ module Glue
if search_options[:facets]
search_options[:facets].each_pair do |name, value|
- facet name do
+ facet(name, :facet_filter => facet_filters) do
terms value, :size => facet_size
+
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment