Commit d39451e482d50afaed0105c38b049003aef6563c
1 parent
7ebda177
Exists in
staging
and in
26 other branches
solr: only uses environment_id in filter query on indexed tables
This avoids solr throwing an error when it tries to filter by unindexed column.
Showing
1 changed file
with
5 additions
and
4 deletions
Show diff stats
plugins/solr/lib/solr_plugin/search_helper.rb
| ... | ... | @@ -42,12 +42,14 @@ module SolrPlugin::SearchHelper |
| 42 | 42 | asset_class(asset).table_name |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | - def filters(asset) | |
| 45 | + def filters(asset, environment) | |
| 46 | 46 | case asset |
| 47 | 47 | when :products |
| 48 | 48 | ['solr_plugin_public:true', 'enabled:true'] |
| 49 | - when :events | |
| 49 | + when :catalog, :events, :categories, :product_categories | |
| 50 | 50 | [] |
| 51 | + when :profiles, :people, :organizations, :communities, :enterprises | |
| 52 | + ['solr_plugin_public:true', 'environment_id:%s' % environment.id] | |
| 51 | 53 | else |
| 52 | 54 | ['solr_plugin_public:true'] |
| 53 | 55 | end |
| ... | ... | @@ -88,8 +90,7 @@ module SolrPlugin::SearchHelper |
| 88 | 90 | solr_options[:all_facets] = true |
| 89 | 91 | end |
| 90 | 92 | solr_options[:filter_queries] ||= [] |
| 91 | - solr_options[:filter_queries] += filters(asset) | |
| 92 | - solr_options[:filter_queries] << "environment_id:#{environment.id}" | |
| 93 | + solr_options[:filter_queries] += filters(asset, environment) | |
| 93 | 94 | solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category |
| 94 | 95 | |
| 95 | 96 | solr_options[:boost_functions] ||= [] | ... | ... |