Module: Trestle::Search::SunspotAdapter

Defined in:
lib/trestle/search/adapters/sunspot_adapter.rb

Instance Method Summary collapse

Instance Method Details

#count(search) ⇒ Object



8
9
10
# File 'lib/trestle/search/adapters/sunspot_adapter.rb', line 8

def count(search)
  search.execute.hits.total_count
end

#finalize_collection(search) ⇒ Object



24
25
26
# File 'lib/trestle/search/adapters/sunspot_adapter.rb', line 24

def finalize_collection(search)
  search.execute.results
end

#merge_scopes(scope, other) ⇒ Object



4
5
6
# File 'lib/trestle/search/adapters/sunspot_adapter.rb', line 4

def merge_scopes(scope, other)
  other
end

#paginate(search, params) ⇒ Object



18
19
20
21
22
# File 'lib/trestle/search/adapters/sunspot_adapter.rb', line 18

def paginate(search, params)
  search.build do
    paginate(page: params[:page], per_page: 25)
  end
end

#sort(search, field, order) ⇒ Object



12
13
14
15
16
# File 'lib/trestle/search/adapters/sunspot_adapter.rb', line 12

def sort(search, field, order)
  search.build do
    order_by(field, order)
  end
end