Class: Calagator::Venue::SearchEngine::ApacheSunspot
- Inherits:
-
Struct
- Object
- Struct
- Calagator::Venue::SearchEngine::ApacheSunspot
- Defined in:
- app/models/calagator/venue/search_engine/apache_sunspot.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#query ⇒ Object
Returns the value of attribute query.
Class Method Summary collapse
- .configure ⇒ Object
- .configured? ⇒ Boolean
-
.search(*args) ⇒ Object
Return an Array of non-duplicate Venue instances matching the search
query
..
Instance Method Summary collapse
-
#initialize(*args) ⇒ ApacheSunspot
constructor
A new instance of ApacheSunspot.
- #search ⇒ Object
Constructor Details
#initialize(*args) ⇒ ApacheSunspot
Returns a new instance of ApacheSunspot.
45 46 47 48 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 45 def initialize(*args) super self.class.configure unless self.class.configured? end |
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts
6 7 8 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 6 def opts @opts end |
#query ⇒ Object
Returns the value of attribute query
6 7 8 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 6 def query @query end |
Class Method Details
.configure ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 21 def self.configure Venue.searchable do text :title, default_boost: 3 string :title text :description text :address text :street_address text :postal_code text :locality text :region text :tag_list, default_boost: 3 text :url boolean :closed boolean :wifi boolean :duplicate_for_solr do |record| record.duplicate_of_id.present? end end end |
.configured? ⇒ Boolean
41 42 43 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 41 def self.configured? Venue.respond_to?(:solr_search) end |
.search(*args) ⇒ Object
Return an Array of non-duplicate Venue instances matching the search query
..
Options:
-
:order => How to order the entries? Defaults to :score. Permitted values:
-
:score => Sort with most relevant matches first
-
:name => Sort by event title
-
:title => same as :name
-
-
:limit => Maximum number of entries to return. Defaults to 50.
-
:wifi => Require wifi
-
:include_closed => Include closed venues? Defaults to false.
17 18 19 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 17 def self.search(*args) new(*args).search end |
Instance Method Details
#search ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/models/calagator/venue/search_engine/apache_sunspot.rb', line 50 def search Venue.solr_search do keywords query order_by *order with :duplicate_for_solr, false with :wifi, true if wifi with :closed, false unless include_closed end.results.take(limit) end |