Class: Calagator::Event::SearchEngine::ApacheSunspot

Inherits:
Struct
  • Object
show all
Defined in:
app/models/calagator/event/search_engine/apache_sunspot.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ApacheSunspot

Returns a new instance of ApacheSunspot.



50
51
52
53
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 50

def initialize(*args)
  super
  self.class.configure unless self.class.configured?
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts

Returns:

  • (Object)

    the current value of opts



5
6
7
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 5

def opts
  @opts
end

#queryObject

Returns the value of attribute query

Returns:

  • (Object)

    the current value of query



5
6
7
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 5

def query
  @query
end

Class Method Details

.configureObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 25

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) { |event| event.duplicate? }
  end
end

.configured?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 46

def self.configured?
  Event.respond_to?(:solr_search)
end

.score?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 21

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.



17
18
19
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 17

def self.search(*args)
  new(*args).all
end

Instance Method Details

#allObject



55
56
57
# File 'app/models/calagator/event/search_engine/apache_sunspot.rb', line 55

def all
  current_events + past_events
end