Class: Calagator::Event::SearchEngine::ApacheSunspot
- Inherits:
-
Struct
- Object
- Struct
- Calagator::Event::SearchEngine::ApacheSunspot
- Defined in:
- app/models/calagator/event/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
- .score? ⇒ Boolean
-
.search(*args) ⇒ Object
Return an Array of non-duplicate Event instances matching the search
query
..
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(*args) ⇒ ApacheSunspot
constructor
A new instance of ApacheSunspot.
Constructor Details
#initialize(*args) ⇒ ApacheSunspot
Returns a new instance of ApacheSunspot.
51 52 53 54 |
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 51 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/event/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/event/search_engine/apache_sunspot.rb', line 6 def query @query end |
Class Method Details
.configure ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 26 def self.configure Event.searchable do text :title, default_boost: 3 string :title text :description text :tag_list, default_boost: 3 text :url time :start_time time :end_time text(:venue_title) { venue.try(:title) } string(:venue_title) { venue.try(:title) } boolean(:duplicate) { duplicate? } end end |
.configured? ⇒ Boolean
47 48 49 |
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 47 def self.configured? Event.respond_to?(:solr_search) end |
.score? ⇒ Boolean
22 23 24 |
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 22 def self.score? true end |
.search(*args) ⇒ Object
Return an Array of non-duplicate Event instances matching the search query
..
Options:
-
:order => How to order the entries? Defaults to :score. Permitted values:
-
:score => Sort with most relevant matches first
-
:date => Sort by date
-
:name => Sort by event title
-
:title => same as :name
-
:venue => Sort by venue title
-
-
:limit => Maximum number of entries to return. Defaults to 50.
-
:skip_old => Return old entries? Defaults to false.
18 19 20 |
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 18 def self.search(*args) new(*args).all end |
Instance Method Details
#all ⇒ Object
56 57 58 |
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 56 def all current_events + past_events end |