diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb index 3bb929c..adf5900 100644 --- a/app/controllers/public/search_controller.rb +++ b/app/controllers/public/search_controller.rb @@ -44,7 +44,7 @@ class SearchController < PublicController def people if !@empty_query - full_text_search ['visible:true'] + full_text_search ['public:true'] else @results[@asset] = @environment.people.visible.send(@filter).paginate(paginate_options) @facets = {} @@ -53,13 +53,13 @@ class SearchController < PublicController def products if !@empty_query - full_text_search ['visible:true'] + full_text_search ['public:true'] end end def enterprises if !@empty_query - full_text_search ['visible:true'] + full_text_search ['public:true'] else @filter_title = _('Enterprises from network') @results[@asset] = @environment.enterprises.visible.paginate(paginate_options) @@ -68,7 +68,7 @@ class SearchController < PublicController def communities if !@empty_query - full_text_search ['visible:true'] + full_text_search ['public:true'] else @results[@asset] = @environment.communities.visible.send(@filter).paginate(paginate_options) end @@ -291,6 +291,7 @@ class SearchController < PublicController solr_options[:order] = params[:order_by] if params[:order_by] solr_options[:filter_queries] ||= [] solr_options[:filter_queries] += filters + solr_options[:filter_queries] << "environment_id:#{environment.id}" ret = asset_class.find_by_contents(@query, paginate_options, solr_options) @results[@asset] = ret[:results] diff --git a/app/models/article.rb b/app/models/article.rb index 6f640cc..5ca4e23 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -627,6 +627,9 @@ class Article < ActiveRecord::Base def public self.public? end + def environment_id + profile.environment_id + end public acts_as_faceted :fields => { @@ -639,7 +642,11 @@ class Article < ActiveRecord::Base :category_query => proc { |c| "f_category:\"#{c.name}\"" }, :order => [:f_type, :f_published_at, :f_profile_type, :f_category] - acts_as_searchable :additional_fields => [ {:name => {:type => :string}}, {:public => {:type => :boolean}}] + facets_fields_for_solr, + acts_as_searchable :additional_fields => [ + {:name => {:type => :string}}, + {:public => {:type => :boolean}}, + {:environment_id => {:type => :integer}}, + ] + facets_fields_for_solr, :exclude_fields => [:setting], :include => [:profile], :facets => facets_option_for_solr, diff --git a/app/models/product.rb b/app/models/product.rb index 0257125..87544a5 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -93,7 +93,7 @@ class Product < ActiveRecord::Base end def public? - enterprise.public_profile + enterprise.public? end def formatted_value(value) @@ -181,6 +181,12 @@ class Product < ActiveRecord::Base def f_qualifier product_qualifier_ids end + def public + self.public? + end + def environment_id + enterprise.environment_id + end public acts_as_faceted :fields => { @@ -193,6 +199,8 @@ class Product < ActiveRecord::Base acts_as_searchable :additional_fields => [ {:name => {:type => :text, :boost => 5.0}}, {:price_sort => {:type => :decimal}}, + {:public => {:type => :boolean}}, + {:environment_id => {:type => :integer}}, {:name_or_category => {:type => :string, :as => :name_or_category_sort, :boost => 2.0}}, :category_full_name ] + facets.keys.map{|i| {i => :facet}}, :include => [:enterprise, :qualifiers, :certifiers, :product_category], diff --git a/app/models/profile.rb b/app/models/profile.rb index 8637e16..07837b3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -851,6 +851,9 @@ private :generate_url, :url_options def name_sort name end + def public + self.public? + end public acts_as_faceted :fields => { @@ -861,7 +864,9 @@ private :generate_url, :url_options :order => [:f_type, :f_categories] acts_as_searchable :additional_fields => [ - :extra_data_for_index, {:name_sort => {:type => :string}} ] + facets.keys.map{|i| {i => :facet}}, + {:name_sort => {:type => :string}}, + {:public => {:type => :boolean}}, + :extra_data_for_index ] + facets.keys.map{|i| {i => :facet}}, :boost => proc {|p| 10 if p.enabled}, :facets => facets.keys handle_asynchronously :solr_save -- libgit2 0.21.2