Module: SocialStream::Search
- Defined in:
- lib/social_stream/search.rb
Constant Summary collapse
- MIN_QUERY =
TODO: sync with ThinkingSphinx min_infix_len and min_prefix_len options
3
Class Method Summary collapse
- .count(query, subject, options = {}) ⇒ Object
- .keys(search_type) ⇒ Object
- .models(search_type, key = nil) ⇒ Object
- .options_for_type_select ⇒ Object
- .search(query, subject, options = {}) ⇒ Object
Class Method Details
.count(query, subject, options = {}) ⇒ Object
51 52 53 |
# File 'lib/social_stream/search.rb', line 51 def count(query, subject, = {}) ThinkingSphinx.count *args_for_search(query, subject, ) end |
.keys(search_type) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/social_stream/search.rb', line 7 def keys(search_type) case search_type when :quick SocialStream.quick_search_models when :extended extended_search_models.keys end end |
.models(search_type, key = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/social_stream/search.rb', line 22 def models(search_type, key = nil) case search_type when :quick quick_search_models when :extended if key.present? if extended_search_models.keys.include?(key.to_sym) extended_search_models[key.to_sym] else if extended_search_models.values.flatten.map{ |k| k.to_s }.include?(key.to_s.classify) [key.to_s.classify.constantize] else raise "Unknown search key #{ key }" end end else extended_search_models.values.flatten end when :repository SocialStream.repository_models.map{ |m| m.to_s.classify.constantize } else raise "Unknown search type #{ search_type }" end end |
.options_for_type_select ⇒ Object
16 17 18 19 20 |
# File 'lib/social_stream/search.rb', line 16 def keys(:extended).map{ |k| [ I18n.t("#{ k }", count: :other), k ] }.unshift([ I18n.t("search.show_all"), "" ]) end |
.search(query, subject, options = {}) ⇒ Object
47 48 49 |
# File 'lib/social_stream/search.rb', line 47 def search(query, subject, = {}) ThinkingSphinx.search *args_for_search(query, subject, ) end |