Class: Sunspot::Query::CompositeFulltext

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/query/composite_fulltext.rb

Instance Method Summary collapse

Constructor Details

#initializeCompositeFulltext

Returns a new instance of CompositeFulltext.



4
5
6
# File 'lib/sunspot/query/composite_fulltext.rb', line 4

def initialize
  @components = []
end

Instance Method Details

#add(keywords) ⇒ Object



8
9
10
11
# File 'lib/sunspot/query/composite_fulltext.rb', line 8

def add(keywords)
  @components << dismax = Dismax.new(keywords)
  dismax
end

#add_location(field, lat, lng, options) ⇒ Object



13
14
15
16
# File 'lib/sunspot/query/composite_fulltext.rb', line 13

def add_location(field, lat, lng, options)
  @components << location = Geo.new(field, lat, lng, options)
  location
end

#to_paramsObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/sunspot/query/composite_fulltext.rb', line 18

def to_params
  case @components.length
  when 0
    {}
  when 1
    @components.first.to_params.merge(:fl => '* score')
  else
    to_subqueries.merge(:fl => '* score')
  end
end