Commit 1b6b699fa992fbead80d228190502330b645b2cb
1 parent
577cdbee
Exists in
master
and in
29 other branches
Check for public instead of visible
Also only search on the current environment
Showing
4 changed files
with
28 additions
and
7 deletions
Show diff stats
app/controllers/public/search_controller.rb
... | ... | @@ -44,7 +44,7 @@ class SearchController < PublicController |
44 | 44 | |
45 | 45 | def people |
46 | 46 | if !@empty_query |
47 | - full_text_search ['visible:true'] | |
47 | + full_text_search ['public:true'] | |
48 | 48 | else |
49 | 49 | @results[@asset] = @environment.people.visible.send(@filter).paginate(paginate_options) |
50 | 50 | @facets = {} |
... | ... | @@ -53,13 +53,13 @@ class SearchController < PublicController |
53 | 53 | |
54 | 54 | def products |
55 | 55 | if !@empty_query |
56 | - full_text_search ['visible:true'] | |
56 | + full_text_search ['public:true'] | |
57 | 57 | end |
58 | 58 | end |
59 | 59 | |
60 | 60 | def enterprises |
61 | 61 | if !@empty_query |
62 | - full_text_search ['visible:true'] | |
62 | + full_text_search ['public:true'] | |
63 | 63 | else |
64 | 64 | @filter_title = _('Enterprises from network') |
65 | 65 | @results[@asset] = @environment.enterprises.visible.paginate(paginate_options) |
... | ... | @@ -68,7 +68,7 @@ class SearchController < PublicController |
68 | 68 | |
69 | 69 | def communities |
70 | 70 | if !@empty_query |
71 | - full_text_search ['visible:true'] | |
71 | + full_text_search ['public:true'] | |
72 | 72 | else |
73 | 73 | @results[@asset] = @environment.communities.visible.send(@filter).paginate(paginate_options) |
74 | 74 | end |
... | ... | @@ -291,6 +291,7 @@ class SearchController < PublicController |
291 | 291 | solr_options[:order] = params[:order_by] if params[:order_by] |
292 | 292 | solr_options[:filter_queries] ||= [] |
293 | 293 | solr_options[:filter_queries] += filters |
294 | + solr_options[:filter_queries] << "environment_id:#{environment.id}" | |
294 | 295 | |
295 | 296 | ret = asset_class.find_by_contents(@query, paginate_options, solr_options) |
296 | 297 | @results[@asset] = ret[:results] | ... | ... |
app/models/article.rb
... | ... | @@ -627,6 +627,9 @@ class Article < ActiveRecord::Base |
627 | 627 | def public |
628 | 628 | self.public? |
629 | 629 | end |
630 | + def environment_id | |
631 | + profile.environment_id | |
632 | + end | |
630 | 633 | public |
631 | 634 | |
632 | 635 | acts_as_faceted :fields => { |
... | ... | @@ -639,7 +642,11 @@ class Article < ActiveRecord::Base |
639 | 642 | :category_query => proc { |c| "f_category:\"#{c.name}\"" }, |
640 | 643 | :order => [:f_type, :f_published_at, :f_profile_type, :f_category] |
641 | 644 | |
642 | - acts_as_searchable :additional_fields => [ {:name => {:type => :string}}, {:public => {:type => :boolean}}] + facets_fields_for_solr, | |
645 | + acts_as_searchable :additional_fields => [ | |
646 | + {:name => {:type => :string}}, | |
647 | + {:public => {:type => :boolean}}, | |
648 | + {:environment_id => {:type => :integer}}, | |
649 | + ] + facets_fields_for_solr, | |
643 | 650 | :exclude_fields => [:setting], |
644 | 651 | :include => [:profile], |
645 | 652 | :facets => facets_option_for_solr, | ... | ... |
app/models/product.rb
... | ... | @@ -93,7 +93,7 @@ class Product < ActiveRecord::Base |
93 | 93 | end |
94 | 94 | |
95 | 95 | def public? |
96 | - enterprise.public_profile | |
96 | + enterprise.public? | |
97 | 97 | end |
98 | 98 | |
99 | 99 | def formatted_value(value) |
... | ... | @@ -181,6 +181,12 @@ class Product < ActiveRecord::Base |
181 | 181 | def f_qualifier |
182 | 182 | product_qualifier_ids |
183 | 183 | end |
184 | + def public | |
185 | + self.public? | |
186 | + end | |
187 | + def environment_id | |
188 | + enterprise.environment_id | |
189 | + end | |
184 | 190 | public |
185 | 191 | |
186 | 192 | acts_as_faceted :fields => { |
... | ... | @@ -193,6 +199,8 @@ class Product < ActiveRecord::Base |
193 | 199 | acts_as_searchable :additional_fields => [ |
194 | 200 | {:name => {:type => :text, :boost => 5.0}}, |
195 | 201 | {:price_sort => {:type => :decimal}}, |
202 | + {:public => {:type => :boolean}}, | |
203 | + {:environment_id => {:type => :integer}}, | |
196 | 204 | {:name_or_category => {:type => :string, :as => :name_or_category_sort, :boost => 2.0}}, |
197 | 205 | :category_full_name ] + facets.keys.map{|i| {i => :facet}}, |
198 | 206 | :include => [:enterprise, :qualifiers, :certifiers, :product_category], | ... | ... |
app/models/profile.rb
... | ... | @@ -851,6 +851,9 @@ private :generate_url, :url_options |
851 | 851 | def name_sort |
852 | 852 | name |
853 | 853 | end |
854 | + def public | |
855 | + self.public? | |
856 | + end | |
854 | 857 | public |
855 | 858 | |
856 | 859 | acts_as_faceted :fields => { |
... | ... | @@ -861,7 +864,9 @@ private :generate_url, :url_options |
861 | 864 | :order => [:f_type, :f_categories] |
862 | 865 | |
863 | 866 | acts_as_searchable :additional_fields => [ |
864 | - :extra_data_for_index, {:name_sort => {:type => :string}} ] + facets.keys.map{|i| {i => :facet}}, | |
867 | + {:name_sort => {:type => :string}}, | |
868 | + {:public => {:type => :boolean}}, | |
869 | + :extra_data_for_index ] + facets.keys.map{|i| {i => :facet}}, | |
865 | 870 | :boost => proc {|p| 10 if p.enabled}, |
866 | 871 | :facets => facets.keys |
867 | 872 | handle_asynchronously :solr_save | ... | ... |